Search code examples
pythontensorflowdeep-learningtflearnnvidia-jetson

Tensorflow & TFlearn Error - unexpected argument 'keepdims'


I have installed Tensorflow and Tflearn on my Jetson Tx1. Tensorflow works and the program I'm trying to run works on my mac. But I get this error when I run it on my 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'

The code for the neural net

# 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')

Solution

  • For Tensorflow v1.4 or below, the parameter to preserve dimensions is written keep_dims (with underscore). The change (to keepdims, currently with retro-compatibility) was introduced in v1.5.

    It is thus possible that your TFlearn version is too recent for your Tensorflow. Upgrading the latter may solve your problem.