[英]ERROR: Could not find a version that satisfies the requirement tensorflow==1.14.0
[英]Error porting Tensorflow Keras model to Tensorflow Version 1.14.0
我最近编写了一个小神经网络来和我玩井字游戏。 这真的是我自己写的第一个NN。 今天我想通过 Google Collab 把它展示给朋友,我得到了这个错误:
model.fit(train_layout, train_place, epochs=3000)
^
SyntaxError: invalid syntax
我以前从来没有遇到过这个错误。 我认为这与使用 1.14.0 版的 Google Collag 和使用 1.13.1 版的我有关
这是我的代码:
import tensorflow as tf
from tensorflow import keras
model = keras.Sequential([
keras.layers.Dense(9, activation=tf.nn.tanh),
keras.layers.Dense(128, activation=tf.nn.relu),
keras.layers.Dense(256, activation=tf.nn.relu),
keras.layers.Dense(96, activation=tf.nn.relu),
keras.layers.Dense(9, activation=tf.nn.softmax)
])
gd = tf.train.GradientDescentOptimizer(0.2)
model.compile(gd, loss='mean_squared_error', metrics=['accuracy'])
model.fit(train_layout, train_place, epochs=3000)
训练数据如下所示:
train_layout = np.array([[0, 0, 0, 0, 1, 0, 0, 0, 0]])
train_place = np.array([[0, 1, 0, 0, 0, 0, 0, 0, 0]])
(当然只有一个数据块=D)
提前感谢您的帮助-nailuj05
你实际上给自己一个答案。
我以前从来没有遇到过这个错误。 我认为这与使用 1.14.0 版的 Google Collag 和使用 1.13.1 版的我有关
我认为解决此问题的一种方法是保存json
model 并手动检查操作员名称是否已在补丁中更改。 如果您的 model 是.h5
,我不知道有什么解决方案来处理它。
首先,我在 collab 中复制粘贴的代码,我得到的错误是无法构建密集层。
其次,对于 1 块井字游戏这样一个简单的问题,仅仅倾倒各种大小的密集层并不是一个好主意……我相信你会遇到过拟合……
第三也是最重要的一个是....您忘记提及输入层大小...这可能是错误的根本原因...
如果您查看错误,它会显示syntax error
,这主要是因为您忘记了代码中要编写的内容,例如括号、逗号或有时是空格等。我认为这不是因为 tensorflow 版本。 我可以使用 TF 1.14 和 1.13 在 colab 中运行此代码,它只是显示了一个错误,可以通过在第一层之前定义输入形状来消除该错误。 例如,
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(9, activation=tf.nn.tanh),
keras.layers.Dense(128, activation=tf.nn.relu),
keras.layers.Dense(256, activation=tf.nn.relu),
keras.layers.Dense(96, activation=tf.nn.relu),
keras.layers.Dense(9, activation=tf.nn.softmax)
])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.