Describes how to get the output of any layer in the network with Keras.
predict.py
from keras import backend as K
get_1st_layer_output = K.function([model.layers[0].input],
[model.layers[5].output])
layer_output = get_1st_layer_output([img,])
img_layer_5 = layer_output[0][0,:]
Specify the input layer and the layer you want to get in the argument of K.finction (). Create a function. If you give the function an input (here, an image) as an argument, the layer you want to get You can get the output !!
Recommended Posts