[英]How to fix: AttributeError: module 'tensorflow' has no attribute 'optimizers' in JupyterNotebook (using colab.research)
I am trying to run my neural network in colab.research page, but I am still getting error AttributeError: module 'tensorflow' has no attribute 'optimizers'
at this line:我正在尝试在 colab.research 页面中运行我的神经网络,但我仍然收到错误
AttributeError: module 'tensorflow' has no attribute 'optimizers'
在这一行:
opt = tensorflow.optimizers.RMSprop(learning_rate=0.00001, decay=1e-6)
My importing part from the code:我从代码中导入的部分:
import tensorflow
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten
from tensorflow.keras.layers import Conv2D, MaxPooling2D
from keras import optimizers
import os
Tensorflow version: Tensorflow 版本:
print(tensroflow.__version__) # 1.15.0
optimizers is part of the keras library.优化器是 keras 库的一部分。 Either do
要么做
from tensorflow.keras import optimizers
And then use然后使用
optimizers.RMSprop()
in your code Or在您的代码中或
opt = tensorflow.keras.optimizers.RMSprop()
Use this:用这个:
opt = tensorflow.compat.v1.train.RMSPropOptimizer(learning_rate=0.00001, decay=1e-6)
Reference: https://www.tensorflow.org/api_docs/python/tf/compat/v1/train/RMSPropOptimizer参考: https://www.tensorflow.org/api_docs/python/tf/compat/v1/train/RMSPropOptimizer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.