简体   繁体   English

Tensorflow细长列车和验证初始模型

[英]Tensorflow slim train and validate inception model

I'm trying to fine tune inception models, and validate it with test data. 我正在尝试微调初始模型,并使用测试数据进行验证。 But all the examples given at tensorflow slime web page only either fine-tuning or testing, there is not any example that doing both at same graph and session. 但是在tensorflow slime网页上给出的所有示例都只是微调或测试,没有任何例子可以在同一个图形和会话中同时进行。

Basically I want to this. 基本上我想要这个。

with tf.Graph().as_default():
 image, image_raw,  label,image_name, label_name = dut.distorted_inputs(params,is_training=is_training)
 test_image, test_image_raw,  test_label,test_image_name, test_label_name = dut.distorted_inputs(params,is_training=False)

 # I'm creating as it is suggested at github slim page:
 logits, _ =inception.inception_v2(image, num_classes=N, is_training=True)
 tf.get_variable_scope().reuse_variables()
 logits_tes, _ =inception.inception_v2(test_image, num_classes=N, is_training=Test)
 err=tf.sub(logits, label)
 losses = tf.reduce_mean(tf.reduce_sum(tf.square(err)))
 # total_loss = model_loss+losses
 total_loss = losses+slim.losses.get_total_loss()
 test_err=tf.sub(test_logits, test_label)
 test_loss= tf.reduce_mean(tf.reduce_sum(tf.square(test_err)))

 optimizer = tf.train.AdamOptimizer(learning_rate=0.001)
 train_op = slim.learning.create_train_op(total_loss, optimizer)

 final_loss = slim.learning.train(
     train_op,
     logdir=params["cp_file"],
     init_fn=ut.get_init_fn(slim,params),
     number_of_steps=2,
     summary_writer=summary_writer
 )

this code fails As it can be seen, I don't have loop separately to call my test models, I want to test my model on my test data at each 10th batch. 这段代码失败可以看出,我没有单独循环来调用我的测试模型,我想在每个第10批测试数据上测试我的模型。

是否使用number_of_steps = 10调用train然后使用评估代码工作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM