Tensorflow 和 TLearn 错误 - 意外参数 'keepdims'
Tensorflow & TFlearn Error - unexpected argument 'keepdims'
我已经在我的 Jetson Tx1 上安装了 Tensorflow 和 Tflearn。 Tensorflow 工作正常,我正在尝试 运行 的程序在我的 mac 上工作。但是当我 运行 在我的 jetson 上时,我得到了这个错误。
Traceback (most recent call last):
File "net.py", line 164, in <module>
net = tflearn.regression(net, optimizer='adam', learning_rate=0.00001)
File "/usr/local/lib/python3.5/dist-packages/tflearn/layers/estimator.py", line 174, in regression
loss = objectives.get(loss)(incoming, placeholder)
File "/usr/local/lib/python3.5/dist-packages/tflearn/objectives.py", line 66, in categorical_crossentropy
keepdims=True)
TypeError: reduce_sum() got an unexpected keyword argument 'keepdims'
神经网络的代码
# Network building
net = tflearn.input_data([None, 25])
net = tflearn.embedding(net, input_dim=len(words), output_dim=256) #Embedding instead of one hot encoding.
net = tflearn.lstm(net, 256, dropout=0.9) #0.9, 0.00001, 30 was good -->63%
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy', learning_rate=0.00001)
# Training
model = tflearn.DNN(net, tensorboard_verbose=0)
model.fit(x_train, y_train, n_epoch=15, validation_set=(x_test, y_test), show_metric=True, batch_size=30)
model.save('mod.model')
对于 Tensorflow v1.4 或以下版本,保留维度的参数写为 keep_dims
(带下划线)。 v1.5 中引入了更改(至 keepdims
,目前具有追溯兼容性)。
因此,您的 TFlearn 版本可能对于您的 Tensorflow 来说太新了。升级后者可能会解决你的问题。
我已经在我的 Jetson Tx1 上安装了 Tensorflow 和 Tflearn。 Tensorflow 工作正常,我正在尝试 运行 的程序在我的 mac 上工作。但是当我 运行 在我的 jetson 上时,我得到了这个错误。
Traceback (most recent call last):
File "net.py", line 164, in <module>
net = tflearn.regression(net, optimizer='adam', learning_rate=0.00001)
File "/usr/local/lib/python3.5/dist-packages/tflearn/layers/estimator.py", line 174, in regression
loss = objectives.get(loss)(incoming, placeholder)
File "/usr/local/lib/python3.5/dist-packages/tflearn/objectives.py", line 66, in categorical_crossentropy
keepdims=True)
TypeError: reduce_sum() got an unexpected keyword argument 'keepdims'
神经网络的代码
# Network building
net = tflearn.input_data([None, 25])
net = tflearn.embedding(net, input_dim=len(words), output_dim=256) #Embedding instead of one hot encoding.
net = tflearn.lstm(net, 256, dropout=0.9) #0.9, 0.00001, 30 was good -->63%
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net, optimizer='adam', loss='categorical_crossentropy', learning_rate=0.00001)
# Training
model = tflearn.DNN(net, tensorboard_verbose=0)
model.fit(x_train, y_train, n_epoch=15, validation_set=(x_test, y_test), show_metric=True, batch_size=30)
model.save('mod.model')
对于 Tensorflow v1.4 或以下版本,保留维度的参数写为 keep_dims
(带下划线)。 v1.5 中引入了更改(至 keepdims
,目前具有追溯兼容性)。
因此,您的 TFlearn 版本可能对于您的 Tensorflow 来说太新了。升级后者可能会解决你的问题。