Skip to content
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

{NameError}name 'uses_learning_phase' is not defined #13

Closed
valendin opened this issue Sep 16, 2019 · 10 comments
Closed

{NameError}name 'uses_learning_phase' is not defined #13

valendin opened this issue Sep 16, 2019 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed Keras/ Tensorflow Issues pertaining to keras/ tf implementation of Mish

Comments

@valendin
Copy link

valendin commented Sep 16, 2019

When using in an RNN, I get {NameError}name 'uses_learning_phase' is not defined when applying a Dense layer on the output of an LSTM.

Tensorflow 1.14

@digantamisra98 digantamisra98 added bug Something isn't working help wanted Extra attention is needed Keras/ Tensorflow Issues pertaining to keras/ tf implementation of Mish labels Sep 16, 2019
@digantamisra98
Copy link
Owner

Hi. Can you please provide the code so that I can replicate the error you're receiving along with the log. I haven't used Mish as of now on a LSTM so I'll have to check to validate the same. Meanwhile, I'm referring to these issue forums here:

  1. NameError name 'uses_learning_phase' is not defined when using Keras TimeDistributed with batch_shape on Input tensorflow/tensorflow#23425
  2. Problem with TimeDistributed() and Learning Phase keras-team/keras#4178

@digantamisra98
Copy link
Owner

@valendin can you try using Mish from the Tensorflow Addons repository. Implementation is given here - https://github.com/tensorflow/addons/tree/master/tensorflow_addons/activations

@valendin
Copy link
Author

valendin commented Nov 4, 2019

@digantamisra98 will do, have just moved to TF 2.0 so will have to retest

@qo4on
Copy link

qo4on commented Nov 7, 2019

using Mish from the Tensorflow Addons repository. Implementation is given here - https://github.com/tensorflow/addons/tree/master/tensorflow_addons/activations

There is no mish activation:

dir(tfa.activations)
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'absolute_import',
 'division',
 'gelu',
 'hardshrink',
 'lisht',
 'print_function',
 'sparsemax',
 'tanhshrink']

How can I import it to TF 2.0?

@digantamisra98
Copy link
Owner

@qo4on have you updated TFA? Because Mish is here - https://github.com/tensorflow/addons/blob/master/tensorflow_addons/activations/mish.py

@qo4on
Copy link

qo4on commented Nov 7, 2019

I installed latest tfa in Colab:

!pip install tensorflow-addons
import tensorflow_addons as tfa

Maybe I should have used nightly build !pip install tfa-nightly but I didn't find how to import it after the installation. I never used tfa before. Do you know how can I import tfa-nightly?

@digantamisra98
Copy link
Owner

@qo4on I just noticed that they're yet to put out their next release which is why Mish isn't a part of the package even though it's up on the source. You can directly install from the source (Instruction on their Readme) or else wait for the release for this month. I'll put forth an inquiry on when the next release is coming. Thanks

@digantamisra98
Copy link
Owner

@qo4on here's the update - tensorflow/addons#683 (comment)

@qo4on
Copy link

qo4on commented Nov 9, 2019

Eventually I found the way to use Mish from the Tensorflow Addons in Colab:

!pip install tf-nightly==2.1.0.dev20191029
!pip install tfa-nightly
import tensorflow_addons as tfa
dir(tfa.activations)
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'absolute_import',
 'division',
 'gelu',
 'hardshrink',
 'lisht',
 'mish',
 'print_function',
 'rrelu',
 'softshrink',
 'sparsemax',
 'tanhshrink']

@digantamisra98
Copy link
Owner

@qo4on Good to know. Let me know if there is any other issues regarding Mish.
@valendin closing this issue as of now, I believe using Mish from TFA will solve the error. Feel free to re-open it if the issue persists. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed Keras/ Tensorflow Issues pertaining to keras/ tf implementation of Mish
Projects
None yet
Development

No branches or pull requests

3 participants