How to get output from the implementation layer

from keras.models import Sequential
from keras.layers.embeddings import Embedding
from theano import function

model = Sequential()
model.add(Embedding(max_features, 128, input_length = maxlen))

I want to get output from implementation layers. I read the source in keras but did not find a suitable function or attribute. Can anybody help me?

+4
source share
1 answer

You can get output of any level, and not just the implementation layer, as described here :

from keras import backend as K
get_3rd_layer_output = K.function([model.layers[0].input],
                                  [model.layers[3].output])
layer_output = get_3rd_layer_output([X])[0]

In your case, you need model.layers[0].outputinstead model.layers[3].output.

+5
source

All Articles