计算验证集的准确性

时间:2017-07-29 22:50:28

标签: validation tensorflow neural-network conv-neural-network convolution

我将火车和验证设置保存为tfrecord文件。推断提供输入图像并返回logits。损失和准确性计算损失和准确性。使用此代码网络训练良好(列车设置准确度增加和损失减少)。但验证集的准确性几乎是固定的。通过张量板,我发现验证集的计算精度创建了不使用主图权重的新图。如何同时预测验证集的准确性?

def run_training():
train_images,train_labels = read_and_decode_tfrecord_train(train_data_path)
val_images,val_labels = read_and_decode_tfrecord_validation(validation_data_path)

train_images = tf.cast(train_images,tf.float32)/255.
val_images = tf.cast(train_images,tf.float32)/255.

batch_Xs,batch_Ys=tf.train.shuffle_batch([train_images,train_labels],batch_size=500,capacity=500,min_after_dequeue=100)
batch_xs,batch_ys=tf.train.shuffle_batch([val_images,val_labels],batch_size=500,capacity=500,min_after_dequeue=100)

logits=inference(batch_Xs,1)
total_loss = loss(logits,batch_Ys)
train_op = training(total_loss,learning_rate=LEARNING_RATE)
accuracy = evaluation(logits,batch_Ys)

val_logits=inference(batch_xs,1)
val_accuracy = evaluation(val_logits,batch_ys)

saver = tf.train.Saver(tf.all_variables(), max_to_keep=4,)

sess = tf.Session()
init = tf.initialize_all_variables()
sess.run(init)

tf.train.start_queue_runners(sess=sess)

for i in range(NUM_ITER):
    _,loss_value,acc=sess.run([train_op,total_loss,accuracy])
    if i%10==0:
         val_acc,testing_summary_accuracy=sess.run([val_accuracy,testing_summary])
         print 'Iteration:',i, ' Loss:',loss_value,' Train Accuracy:',acc,' Validation Accuracy:',v

0 个答案:

没有答案