1、报错1:ValueError: Only call `softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)
提示出错如下:
Traceback (most recent call last):File "/MNIST/softmax.py", line 12, in <module>cross_entropy2=tf.reduce_sum(tf.nn.softmax_cross_entropy_with_logits(logits, y_))#dont forget tf.reduce_sum()!!File "C:\python35\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 1578, in softmax_cross_entropy_with_logitslabels, logits)File "C:\python35\lib\site-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=..., ...)
解决方案:
# 这个函数不能按以前的方式进行调用了,只能使用命名参数的方式来调用。原来是这样的:
tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y, y_))# 修改需要成这样:
tf.reduce_sum(tf.nn.softmax_cross_entropy_with_logits(logits=logits, labels=y_))