keras.optimizers.adam“找不到模块”在COLAB中运行代码时GPU时出错
我正在尝试运行导入keras.optimizers adam的代码。我想从GPU做到这一点,因为我需要进行长时间的培训。如果我正常运行它可以正常运行,但是每次将运行时环境更改为GPU时,它都找不到模块“ adam”,并给我下面的错误。由于与其他库的兼容性,我正在使用KERAS 2.2.4:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-ca97e5a6925a> in <module>()
8 from keras.models import Sequential
9 from keras.layers import Dense, Activation, Flatten, Convolution2D, Permute
---> 10 from keras.optimizers import Adam
11 import keras.backend as K
12
ImportError: cannot import name 'Adam' from 'keras.optimizers' (/usr/local/lib/python3.7/dist-packages/keras/optimizers.py)
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
I'm trying to run a code importing keras.optimizers Adam. I want to do it from GPU as I need to make a long training. If I run normally it works, but every time I change the runtime enviroment to GPU, it doesn't find the module "Adam" and gives me the error below. I'm using keras 2.2.4 due to compatibilities with other libraries:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-ca97e5a6925a> in <module>()
8 from keras.models import Sequential
9 from keras.layers import Dense, Activation, Flatten, Convolution2D, Permute
---> 10 from keras.optimizers import Adam
11 import keras.backend as K
12
ImportError: cannot import name 'Adam' from 'keras.optimizers' (/usr/local/lib/python3.7/dist-packages/keras/optimizers.py)
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改行:
TO:
它将起作用。
Change the line:
to:
and it'll work.