【发布时间】:2018-03-24 17:53:02
【问题描述】:
我的代码:
def accuracy(pred_labels,true_labels):
true_labels = tf.cast(tf.reshape(true_labels,[-1,1]),tf.float32)
correct_pred = tf.equal(pred_labels,true_labels)
accuracy = tf.reduce_mean(tf.cast(correct_pred,tf.float32))
return accuracy
当我跑步时:
feed_images = tf.placeholder(tf.float32,shape=(None,96,96,3))
feed_labels = tf.placeholder(tf.float32,shape=(None,))
logits = nn_model(feed_images)
cost = loss(logits,feed_labels)
opt_adam = optimizer(cost)
acc = accuracy(logits,feed_labels)
feed_trdict={feed_images:ni,feed_labels:nl}
tr_acc = sess.run(acc,feed_dict = feed_trdict)
我得到所有连续迭代的训练精度为 0.0。
然而不应该如此。
我不明白,代码有什么问题。我在一个博客网站上看到了计算准确率的代码(只有accuracy函数代码)
【问题讨论】:
标签: tensorflow