首页 > 其他 > 详细

ValueError: Only call `sparse_softmax_cross_entropy_with_logits` with named a

时间:2018-11-09 14:07:02      阅读:223      评论:0      收藏:0      [点我收藏+]

第五章中完整的训练MNIST数据的神经网络模型的程序代码中,直接运行程序的话会遇到以下的错误。

把下面的这行代码

 

# 计算交叉熵及其平均值
cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(y,tf.argmax(y_, 1))

#改为

cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=tf.argmax(y_, 1), logits=y)

  

tf.initialize_all_variables.run()
AttributeError: ‘function‘ object has no attribute ‘run‘

  tf.initialize_all_variables.run()

#改为
tf.global_variables_initializer().run()

 



ValueError: Only call `sparse_softmax_cross_entropy_with_logits` with named a

原文:https://www.cnblogs.com/a9999/p/9934725.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!