Tensorflow& TFlearn错误 - 意外参数'keepdims'

时间:2018-04-25 18:18:47

标签: python tensorflow deep-learning tflearn nvidia-jetson

我在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')

1 个答案:

答案 0 :(得分:3)

对于Tensorflow v1.4或更低版本,保留维度的参数写为keep_dims(带下划线)。在v1.5中引入了更改(到keepdims,目前具有逆向兼容性)。

因此,你的Tensorflow可能是你的TFlearn版本太新了。升级后者可以解决您的问题。