0

I'm trying to replicate the code in this blog article How convolutional neural networks see the world

It works well in a CNN where there's no dropout layer but when there's one (or more) dropout layers, I can't directly use the layer.output line because it expects a learning phase.

When I use the recommend way to extract the output of a layer :

get_layer_output = K.function([model.layers[0].input,   K.learning_phase()],
                              [model.layers[layer_index].output])

layer_output = get_3rd_layer_output([input_img, 0])[0]

The problem is that I can't put a placeholder in input_img because it expects "real" data but if I put directly "real" data then the rest of the code doesn't work (creating the loss, gradients and iterating needs a placeholder).

Is there a way I can make this work?

I'm using the Tensorflow backend.

EDIT : I solved my issue by using the K.set_learning_phase() method before doing anything like building my model (I had to start from a new environment and I used the method right after the imports).

Community
  • 1
  • 1
Merwann Selmani
  • 1,066
  • 8
  • 7
  • There shouldn't be any code that requires a placeholder. What kind of error are you getting? – drpng Feb 15 '17 at 18:44
  • If you look at the blog post, he uses `input_img` as a placeholder (to create his function) and `input_img_data` as the data he's giving to the function. But I managed to make it work by using the `K.set_learning_phase()` method before building my model (I tried it yesterday but after building the model). Thank you – Merwann Selmani Feb 16 '17 at 14:12

0 Answers0