Reputation: 429
I am using python2 and i'm trying to get the activations of hidden layer. I am using the following code which is giving me an error:
get_activations = theano.function([my_model.layers[0].input], my_model.layers[0].get_output(train=False),
allow_input_downcast=True)
When I run the code it says:
AttributeError: 'Dense' object has no attribute 'get_output'
I have tried to use my_model.layers[0].output
which also does not work correctly.
What should I do to get the activations from a layer given?
Upvotes: 1
Views: 511
Reputation: 777
attribute get_output
is only defined for old versions of keras (0.3). It no longer exists in version 1.0.
see new syntax (keras doc FAQ)
something like
get_activations = K.function([model.layers[0].input], [model.layers[1].output])
should work since the hidden layer is the second layer in your model (i.e. model.layers[1]
)
Upvotes: 2