(1) You can check Keras FAQ: How can I obtain the output of an intermediate layer? https://keras.io/getting-started/faq/#how-can-i-obtain-the-output-of-an-intermediate-layer
(2) You could use numpy.ndarray.flatten or numpy.reshape to do the transform.