ResNet tensorflow 代码

resnet的图,resnet50有16个残差网络(残差单元),每个残差单元是由三个卷积层组成的这里写图片描述

参考博客,Github代码

原来的代码没有终止,将resnet_main.py中的部分代码改成,设置tf.train.StopAtStepHook停止步数即可。

  tf.app.flags.DEFINE_integer('max_step',100000,'stop step')
  with tf.train.MonitoredTrainingSession(
      checkpoint_dir=FLAGS.log_root,
      hooks=[logging_hook, _LearningRateSetterHook(),tf.train.StopAtStepHook(last_step=FLAGS.max_step)],
      chief_only_hooks=[summary_hook],
      # Since we provide a SummarySaverHook, we need to disable default
      # SummarySaverHook. To do that we set save_summaries_steps to 0.
      save_summaries_steps=0,
      config=tf.ConfigProto(allow_soft_placement=True)) as mon_sess:
      #自动选择运行设备记录设备指派情况
    while not mon_sess.should_stop():
        #执行优化训练
      mon_sess.run(model.train_op)

 

你可能感兴趣的:(神经网络)