使用工具是jupyter notebook,按照视频中代码照敲竟然是错的,无语,使用tab键一步步打开方法选择问题才解决,终于找到Dense方法所在地,附上原代码和改正后代码:
model.add(tf.
keras.Dense(10,activation = 'softmax'))
model.add(tf.
keras.layers.Dense(10,activation = 'softmax'))
原因:TensorFlow 发布的新版本的 API 修改了
tf.mul, tf.sub and tf.neg are deprecated in favor of tf.multiply, tf.subtract and tf.negative.解决方法:使用时将 tf.mul 改成 tf.multiply 即可
其余的 tf.sub 和 tf.neg 也要相应修改为 tf.subtract
初次安装导入Keras时很多人可能都会遇到这样的报错:
AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'
原因是你安装的tensorflow版本和keras版本不匹配!
解决办法:
方案一: 网上有的说直接更新tensorflow:pip install --upgrade ...
在
tensorflow2中是没有这种命名方式的,tf.name_
scope()这个函数在tf1中存在。
我在编写代码时用的就是
tensorflow1 但是还是会报错,这里改正方法是将:
import
tensorflow as tf
import
tensorflow.compat.v1 as tf
在学习《深度学习应用开发Tensorflow实践》课程泰坦尼克号旅客生存预测课程,使用tensorflow高级API kares时,出现AttributeError: module ‘tensorflow’ has no attribute 'keras’问题
解决方法:将model=tf.keras.models.Sequential()替换成model=tf.contrib.keras.mo...
/usr/local/lib/python3.5/dist-packages/prettytensor/
scopes.py in var_and_name_
scope(names)
53 full_name = va...