【问题标题】:Tensorflow & TFlearn Error - unexpected argument 'keepdims'Tensorflow 和 TFlearn 错误 - 意外参数“keepdims”
【发布时间】:2018-04-25 18:18:47
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

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

    因此,您的 TFlearn 版本可能对您的 Tensorflow 来说太新了。升级后者可能会解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 2017-02-25
      • 1970-01-01
      • 2018-06-22
      • 2022-01-04
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多