Keras: How can I get the activation value of each layer?

Created on 11 May 2015  路  6Comments  路  Source: keras-team/keras

I want to see the actual activation values for each layer i, f(W_i * x + b), after each epoch(if this is possible) Is there a way to see it?

Most helpful comment

Sure, you can. See the answer to this question: https://github.com/fchollet/keras/issues/41

All 6 comments

Sure, you can. See the answer to this question: https://github.com/fchollet/keras/issues/41

Oh thanks, but is there a way to do it after each epoch?

Of course. Just run your epochs one at a time. With model.fit(X, y, nb_epoch=1), for instance.

Thanks for the quick reply

@ghost,i use the graph model. But there is something wrong.

model = graph()
model.add_input(name='input0',input_shape=())
model.add_node(Convolution2D(),name='c1',input='input0')
.......

And i want to see the output of the c1,Then

getFeatureMap = theano.function(model.inputs['input0'].input,model.nodes['c1'].get_output(train=False),
allow_input_downcast=True)

But it show me that
TypeError: list indices must be integers, not str

Do you give me some advice,please. Thanks.

More generally you can visualise the output/activations of every layer of your model. I wrote an example with MNIST to show how here:

https://github.com/philipperemy/keras-visualize-activations

So far it's the less painful I've seen.

Was this page helpful?
0 / 5 - 0 ratings