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

Module named "Keras" is not defined #26

Open
nickhdfan opened this issue Feb 27, 2018 · 11 comments
Open

Module named "Keras" is not defined #26

nickhdfan opened this issue Feb 27, 2018 · 11 comments

Comments

@nickhdfan
Copy link

I already installed "keras" and used import function in main.py but when I tried to train SRGAN with MSE this happened.

@perdigas91
Copy link

@nickhdfan, did you managed to solve this? I'm having the same problem. Supposably only tensorflow was needed.

@ryancom16
Copy link

Add the following to ops.py
import keras

apparently keras is actually a dependency for vgg54 training. If you are planning on training vgg54, you will also have to make the change to the following lines of model.py starting at around line 335. change them to look like this:

if type == 'VGG54':
    target_layer = 'vgg_19/conv5/conv5_4'
elif type == 'VGG22':
    target_layer = 'vgg_19/conv2/conv2_2'

@hhsm95
Copy link

hhsm95 commented May 3, 2018

Hi, I have the same error, and the proposed solution didn't work for me, instead I get this new error:

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'dicriminator_train/discriminator/discriminator_unit/dense_layer_2/dense/bias/Adam_1': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device.
	 [[Node: dicriminator_train/discriminator/discriminator_unit/dense_layer_2/dense/bias/Adam_1 = VariableV2[_class=["loc:@discriminator/discriminator_unit/dense_layer_2/dense/bias"], container="", dtype=DT_FLOAT, shape=[1], shared_name="", _device="/device:GPU:0"]()]]

Someone knows why this happens and how to solve it?

@lxk1990727
Copy link

i meet the same question, pip install keras, but doesn't work.
AttributeError: 'module' object has no attribute 'leaky_relu'

@ryancom16
Copy link

@adeoy I believe that you have either installed regular tensorflow (not tensorflow-gpu) or you set CUDA_VISIBLE_DEVICES incorrectly when running the training script.
Note: pip install tensorflow-gpu is a different from pip install tensorflow

@lxk1990727 Sounds like you need to update your tensorflow.

@hhsm95
Copy link

hhsm95 commented May 12, 2018

@ryancom16 In fact I installed regular Tensorflow because I dont a GPU on my PC, but my processors are powerful enough to make this tasks. So, I cant do the next training without a GPU? Or how can I solve this problem?

@AdrienLF
Copy link

AdrienLF commented Jun 2, 2018

Still have the same issue, anyone found a solution?

@AdrienLF
Copy link

You need to add "import keras" in lib/ops.py

@eric-guerin
Copy link

I had the same issue during the second step training (SRGAN with MSE loss) and it was solved by adding "import keras" in lib/ops.py

@rockerritesh
Copy link

yes👍👍" import keras " best solution!!❤❤

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

No branches or pull requests

9 participants