简体   繁体   English

如何修复:AttributeError:模块“tensorflow”在 JupyterNotebook 中没有属性“优化器”(使用 colab.research)

[英]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.

相关问题 如何在 colab.research 上安装 rpy2? - How to install rpy2 on colab.research? 如何解决 AttributeError: module 'keras.optimizers' has no attribute 'Adam' - how to solve AttributeError: module 'keras.optimizers' has no attribute 'Adam' 如何修复 AttributeError:模块“tensorflow”没有属性“ConfigProto” - How can I fix AttributeError: module 'tensorflow' has no attribute 'ConfigProto' 如何在colab.research上通过conda构建库? - How to build libraries via conda on colab.research? AttributeError:模块“keras.optimizers”没有属性“rmsprop” - AttributeError: module 'keras.optimizers' has no attribute 'rmsprop' 修复“AttributeError:模块'tensorflow'没有属性'get_default_graph'” - Fix “AttributeError: module 'tensorflow' has no attribute 'get_default_graph'” 如何解决这个 AttributeError: module 'tensorflow' has no attribute 'get_default_graph'? - How to fix this AttributeError: module 'tensorflow' has no attribute 'get_default_graph'? 如何修复“AttributeError:模块‘tensorflow’没有属性‘get_default_graph’”? - How to fix "AttributeError: module 'tensorflow' has no attribute 'get_default_graph'"? 如何修复 AttributeError:模块“tensorflow”没有属性“reset_default_graph” - How to fix AttributeError: module 'tensorflow' has no attribute 'reset_default_graph' 如何修复此模块'tensorflow'没有属性'lite'? - How to fix this module 'tensorflow' has no attribute 'lite'?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM