-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theano error on trying to adapt the visualization example #2417
Comments
Up |
Your model apparently has a different behavior in training and test mode, and so needs to know what mode it should be using. Use
and pass |
…zers As per keras-team/keras#2417 the train mode is explicitly passed to K.function in order to avoid errors.
I also have similar problem, but occurs when I run use fit() or train_on_batch(), I used K.in_train_phase(pos_score, neg_score) in a user defined layer, pos_score and neg_score are both (symbolic) computed form layer input x. Even if I use K.in_train_phase(pos_score, neg_score), it shows the same error:
|
Good thing that the post right about yours explains what you need to do. |
I am not sure if it is the same problem. As K.learning_phase() used in Embedding layer works just just fine with no additional input. Why does it need to be added when using user defined layer/function? |
For a user defined layer that uses K.in_train_phase, it has to set self.uses_learning_phase = True, so train_on_batch/predict_on_batch and so on can set it correctly. I was following this guide, and didn't notice this. It could have been better if in the guide/doc, setting self.uses_learning_phase = True was explicated mentioned. |
Hi,guys! @kgrm @louismartin @chentingpc @fchollet @bmabey |
Thanks a lot. when I use this blog code How convolutional neural networks see the world visual my own model's layer: conv_1, conv_2, conv_3 ...., I changed the code:
to
it worked fine. Just as the FAQ: Regularization mechanisms, such as Dropout and L1/L2 weight regularization, are turned off at testing time. |
Using
How can I solve this? |
I am getting all zeros for pooled_grads_value for some images. So I followed @fchollet suggestion of adding "K.learning_phase()" and set scalar value of zero for it. But still The entire (512,) array of pooled_grads_value is zero for some of sample images.
I do appreciate if you can help me to resolve the issue. |
I've minimally modified the conv_filter_visualization.py example to run on a network I've trained myself ( see https://gist.github.com/kgrm/67555890a3e07cab709a7a81cc487c31 ). The original script (with the provided weights file) works fine, However, on trying to run my modified one, I get the following theano error:
Please make sure that the boxes below are checked before you submit your issue. Thank you!
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
The text was updated successfully, but these errors were encountered: