• Register
0 votes

Problem :

Getting softmax error as follows
only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)
6 5 3
6,930 points

2 Answers

0 votes

Solution :

I have faced the same issue in the past. After doing a lot of research i found the solution as given below

You need to change the below line


to below given correct line.

tf.nn.softmax_cross_entropy_with_logits(logits=prediction, labels=y)
If you follow above procedure your issue will be resolved.
9 7 4
38,600 points
0 votes


Generally about what the cross entropy function measures. At its core, it takes two probability distributions and estimates the "distance" between them, allowing you to get them closer to one another. For this case, one distribution is the softmax vector (logits), and the second is the one-hot label. I'm not sure if y-conv or y_ is the softmax or one-hot label, so I took a random assumption in the code. 

A very useful method of use case is to have logits and labels of shape [batch_size, num_classes], but higher dimensions are supported, with the axis argument specifying the class dimension.

Backpropagation will only occur into both logits and labels. For disallowing back propagation into labels, pass label tensors through tf.stop_gradient before feeding it to this function.

You have to computes softmax cross entropy between logits and labels.

    labels, logits, axis=-1, name=None

We face this error after changing to what you said ValueError: No gradients provided for any variable, check your graph for ops that do not support gradients, between variables ["<tf.Variable 'Variable:0' shape=(32,) dtype=float32_ref .

10 6 4
31,120 points

Related questions

1 vote
1 answer 122 views
Problem : I am totally trapped from many hours but still my issue is still not fixed. Currently I am trying to use only my CPU version and also trying to get the same No module which is named as 'pywrap_tensorflow_internal' please find below the error : ... 3.6. and TensorFlow is installed at: C:\Python\Python36\lib\site-packages\tensorflow. Kindly guide me in fixing above Tensorflow error.
asked May 11 stewart 4k points
1 vote
2 answers 224 views
Problem : I am beginner to Ancaconda3 and Tensorflow. I have also recently installed Ancaconda3 and Tensorflow. But if I try to import the Tensorflow in the python shell then I often face the below error: ModuleNotFoundError: No module named 'numpy.core._multiarray_umath ... also installed on my box and it can be very successfully imported in the python. Please note currently I am using Windows10.
asked Apr 22 stewart 4k points
1 vote
0 answers 14 views
v = tf.Variable(0) update = tf.compat.v1.assign(v, v+1) init_op = tf.compat.v1.global_variables_initializer() tf.compat.v1.disable_eager_execution() with tf.compat.v1.Session() as session: session.run(init_op) print(session.run(v)) for _ in range(3): session.run(update) print(session.run(v))
asked Jun 21 roshan
0 votes
1 answer 227 views
Problem: If I try to execute the command sess = tf.Session() in the Tensorflow 2.0 environment then I am facing below error message: Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'tensorflow' has no attribute ' ... install numpy==1.16.2 Command Execution as below: Execute the command: import tensorflow as tf Execute the command: sess = tf.Session()
asked Jul 21 Raphael Pacheco 4.9k points