bilylee / SiamFC-TensorFlow

A TensorFlow implementation of the SiamFC tracker
MIT License
358 stars 112 forks source link

关于训练与验证执行的问题 #21

Closed TachibanaYoshino closed 6 years ago

TachibanaYoshino commented 6 years ago

我发现在从零开始训练时,在train_siamese_model.py文件中既定义了train的model,又定义了validation的model_va,在后续代码中,仅执行了训练过程的代码,并没有执行验证过程,也就是说验证模型是建立了但是没有用到。这一点您注意到了吗?

bilylee commented 6 years ago

Hi,

model_val 的执行确实比较隐晦。注意到 https://github.com/bilylee/SiamFC-TensorFlow/blob/17f51563f081281fc7d966602d393715e7ecb469/train_siamese_model.py#L132 将所有 summary 汇聚成一个 operation。而所有 summary 中包含了 validation 的 summary,

  tf.summary.image('exemplar', self.exemplars, family=self.mode)
  tf.summary.image('instance', self.instances, family=self.mode)

  mean_batch_loss, update_op1 = tf.metrics.mean(batch_loss)
  mean_total_loss, update_op2 = tf.metrics.mean(total_loss)
  with tf.control_dependencies([update_op1, update_op2]):
    tf.summary.scalar('batch_loss', mean_batch_loss, family=self.mode)
    tf.summary.scalar('total_loss', mean_total_loss, family=self.mode)

  if self.mode == 'train':
    tf.summary.image('GT', tf.reshape(gt[0], [1] + response_size + [1]), family='GT')
  tf.summary.image('Response', tf.expand_dims(tf.sigmoid(response), -1), family=self.mode)
  tf.summary.histogram('Response', self.response, family=self.mode)

  # Two more metrics to monitor the performance of training
  tf.summary.scalar('center_score_error', center_score_error(response), family=self.mode)
  tf.summary.scalar('center_dist_error', center_dist_error(response), family=self.mode)

为了得到 validation 的 summary (如 batch_loss) 则需要在 validation 集上评估网络。由此,model_val 得到了执行。

TachibanaYoshino commented 6 years ago

恩,阿里嘎多,受益了,多谢