【问题标题】:how should i run this in tensorflow 2.0?我应该如何在 tensorflow 2.0 中运行它?
【发布时间】:2020-08-18 14:54:03
【问题描述】:

我正在尝试在 python 3.7.6 上运行它。 即使我有tflearn 模块,代码也会抛出错误“找不到模块”。 现在我已经安装了 Tensorflow 2.0,我希望这些使用 tf2.0 和 keras 进行编码。

net = tflearn.input_data(shape=[None, len(training[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax")
net = tflearn.regression(net)
net = tflearn.DNN(net)
net.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)
net.save("model.tflearn")

【问题讨论】:

  • 请不要只粘贴代码。先阅读How to ask a good question,详细描述你的问题,你已经尝试过的等等。
  • 现在我试着解释一下。谢谢你纠正我。这是我的第一个问题。
  • tflearn 需要 tensorflow 1

标签: python tensorflow neural-network regression keras-layer


【解决方案1】:

我对 tflearn 了解不多,但在 tensorflow 和 keras 中它看起来像这样-

model = tf.keras.models.Sequential([ 
                                    tf.keras.layers.Dense(8, activation='relu',input_shape=[len(train_dataset.keys())]), 
                                    tf.keras.layers.Dense(8, activation='relu'), 
                           tf.keras.layers.Dense(len(output[0], activation='softmax')])
model.compile(optimizer = 'adam,
              loss = 'mse',
              metrics=['mse'])

model.fit(x, y, epochs=1000)

【讨论】:

  • 我收到错误消息。对于最后一个输出层“类型错误”:moudle 对象不可调用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-19
  • 2020-02-03
  • 1970-01-01
  • 2015-10-07
  • 2015-11-23
相关资源
最近更新 更多