• Register
0 votes
119 views

Problem :

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

Please log in or register to answer this question.

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

tf.nn.softmax_cross_entropy_with_logits(prediction,y)

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

Solution:

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.

tf.nn.softmax_cross_entropy_with_logits(
    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

0 votes
1 answer 5 views
5 views
Problem: Any ideas on what I need to do to fix this? Thanks!
asked Mar 21 ummesalma 29.2k points
0 votes
1 answer 10 views
10 views
Problem: I recently came across tf.nn.sparse_softmax_cross_entropy_with_logits and I can not figure out what the difference is compared to tf.nn.softmax_cross_entropy_with_logits.
asked Mar 21 ummesalma 29.2k points
0 votes
1 answer 3 views
3 views
Problem: i need some help about this problem please help? tf.softmax_cross_entropy_with_logits
asked Mar 18 Rohit kr 17.5k points
0 votes
1 answer 4 views
4 views
Problem: The example code model = tf.keras.Sequential() # Adds a densely-connected layer with 64 units to the model: model.add(layers.Dense(64, activation='relu')) # Add another: model.add(layers.Dense(64, activation='relu')) # Add a softmax layer with 10 output ... and will be removed in a future version. What is the reason of the warning? How should the code be changed to avoid such warnings?
asked Apr 25 sumaiya simi 43.9k points
1 vote
1 answer 26 views
26 views
Problem : I am new in Python, when I try to import tensorflow I get following error : >>> import tensorflow as tf Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named tensorflow Please help me to fix this error .
asked Mar 12 Sabbir Hossain 14.6k points
0 votes
1 answer 37 views
37 views
Problem: importerror: no module named '_pywrap_tensorflow_internal'
asked Feb 18 charles mathews 5.5k points
1 vote
1 answer 481 views
481 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, 2020 stewart 4k points
1 vote
2 answers 1.6K views
1.6K 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, 2020 stewart 4k points
0 votes
1 answer 16 views
16 views
Problem: how to I Solve this: only named arguments may follow *expression HELP! I need help understanding this: only named arguments may follow *expression Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 10 Mashhoodch 13k points
0 votes
1 answer 3 views
3 views
Problem: Don't know how I got this > Resourceexhaustederror: oom when allocating tensor with shape.
asked 1 day ago Irenka Kiri 4.8k points