• Register
0 votes
95 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 15 views
15 views
Problem: importerror: no module named '_pywrap_tensorflow_internal'
asked Feb 18 charles mathews 3.8k points
1 vote
1 answer 334 views
334 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 855 views
855 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
1 vote
0 answers 20 views
20 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, 2020 roshan
0 votes
1 answer 4 views
4 views
Problem : InvalidArgumentError: You must feed a value for placeholder tensor
asked 2 days ago Shovo210 3.1k points
0 votes
1 answer 4 views
4 views
Problem : error: Failed to load the native TensorFlow runtime
asked 4 days ago Shovo210 3.1k points
0 votes
1 answer 4 views
4 views
Problem: object_detection/protos/*.proto: no such file or directory
asked Feb 22 Dan phillip 1.9k points
0 votes
1 answer 484 views
484 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, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 574 views
574 views
Problem: I am having basic knowledge of python, tensorflow, keras. I have read most of the possible solutions for my error they are suggesting wrapping my problematic tensor in the Lambda layer and I have already tried this method but I ... line 1665, in build_map_of_graph     layer, node_index, tensor_index = tensor._keras_history AttributeError: 'Tensor' object has no attribute '_keras_history'
asked May 23, 2020 Martin K 6.6k points