deep-anpr
deep-anpr copied to clipboard
ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)
I have this error running ./train.py. Does anyone know why?
2017-01-30 07:33:03: I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
2017-01-30 07:33:03: I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
2017-01-30 07:33:03: I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
2017-01-30 07:33:03: I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
2017-01-30 07:33:03: I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Traceback (most recent call last):
File "./train.py", line 266, in <module>
initial_weights=initial_weights)
File "./train.py", line 174, in train
digits_loss, presence_loss, loss = get_loss(y, y_)
File "./train.py", line 132, in get_loss
[-1, len(common.CHARS)]))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1578, in softmax_cross_entropy_with_logits
labels, logits)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1533, in _ensure_xent_args
"named arguments (labels=..., logits=..., ...)" % name)
ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)
I took the exact same error. I do not know why but train.py file seems to be wrong or at least wrong for my configuration. I changed some lines in get_loss(y,y_) function as..
.... digits_loss = tf.nn.softmax_cross_entropy_with_logits(logits= tf.reshape(y[:, 1:],[-1,len(common.CHARS)]), labels=tf.reshape(y_[:, 1:], [-1, len(common.CHARS)]))
.... presence_loss = tf.nn.sigmoid_cross_entropy_with_logits(labels=y[:, :1], logits= y_[:, :1])
.....
that it run.
From tensorflow v1, only call softmax_cross_entropy_with_logits
with named arguments (labels=..., logits=..., ...).
Tensorflow 0.x, don't need named arguments
shouldn´t it be this instead? Labels are contained in y_ and logits are the output from the neural net
presence_loss = tf.nn.sigmoid_cross_entropy_with_logits(labels=y_[:, :1], logits= y[:, :1])
I think @mazcallu is right, thanks