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

Support tf.keras #74

Closed
wants to merge 4 commits into from
Closed

Conversation

yu-iskw
Copy link

@yu-iskw yu-iskw commented Sep 13, 2019

Issue

#73

Overview

If an environment has tf.keras, tf.keras is preferentially used to pure keras.

Possible issue

If an user wan to use pure keras but the environment is not a tensorflow backend, an error might occur.

@philipperemy
Copy link
Owner

I have this error when I run it:

from tensorflow.keras.engine.topology import Layer
ModuleNotFoundError: No module named 'tensorflow.keras.engine'

@philipperemy
Copy link
Owner

Package              Version Location
-------------------- ------- -------------------------------
absl-py              0.8.0
astor                0.8.0
gast                 0.3.1
google-pasta         0.1.7
grpcio               1.23.0
h5py                 2.10.0
Keras-Applications   1.0.8
Keras-Preprocessing  1.1.0
Markdown             3.1.1
numpy                1.17.2
pip                  19.2.3
protobuf             3.9.1
setuptools           41.2.0
six                  1.12.0
tensorboard          1.14.0
tensorflow           1.14.0
tensorflow-estimator 1.14.0
termcolor            1.1.0
Werkzeug             0.15.6
wheel                0.33.6
wrapt                1.11.2

@philipperemy
Copy link
Owner

python -c 'from tensorflow.keras.engine.topology import Layer'

@yu-iskw
Copy link
Author

yu-iskw commented Sep 13, 2019

The namespace was wrong. I modified it. Can you take a look at it?

@mimxrt
Copy link

mimxrt commented Sep 20, 2019

ImportError: cannot import name 'Input' from 'tensorflow.keras.models' (unknown location)

change:

from tensorflow.keras.models import Input, Model

to

from tensorflow.keras import Input, Model

@mimxrt
Copy link

mimxrt commented Sep 20, 2019

Another error:

/ws/miniconda3/lib/python3.7/site-packages/tcn/tcn.py in __call__(self, inputs, training)
    148                                              dropout_rate=self.dropout_rate,
    149                                              kernel_initializer=self.kernel_initializer,
--> 150                                              use_batch_norm=self.use_batch_norm)
    151                 skip_connections.append(skip_out)
    152         if self.use_skip_connections:

/ws/miniconda3/lib/python3.7/site-packages/tcn/tcn.py in residual_block(x, training, dilation_rate, nb_filters, kernel_size, padding, activation, dropout_rate, kernel_initializer, use_batch_norm)
     55     # 1x1 conv to match the shapes (channel dimension).
     56     prev_x = Conv1D(nb_filters, 1, padding='same')(prev_x)
---> 57     res_x = keras.layers.add([prev_x, x])
     58     res_x = Activation(activation)(res_x)
     59     return res_x, x

NameError: name 'keras' is not defined

I fixed it by removing the keras. prefix in two occasions and changing

import tensorflow.keras.layers

to

import tensorflow.keras.layers as layers

@yu-iskw
Copy link
Author

yu-iskw commented Sep 20, 2019

@mimxrt Thank you for making sure of it. I have modified some including the tasks.

@philipperemy
Copy link
Owner

See #94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants