【发布时间】:2020-05-04 03:45:28
【问题描述】:
我正在编写此代码来预测最终答案,但我没有得到它。
这是我的代码 将张量流导入为 tf 将 numpy 导入为 np 从张量流导入keras
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')
xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)
ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)
model.fit(xs, ys, epochs=500)
print(model.predict([10.0]))
我收到如下错误: enter image description here
【问题讨论】:
-
请使用三个反引号格式化代码并将所有代码直接添加到问题中(无图像)。
标签: python tensorflow keras