How to save training model at each training step i

2019-07-12 18:47发布

问题:

slim.learning.train(...) accepts two arguments pertaining to saving the model(save_interval_secs) or saving the summaries(save_summaries_secs). The problem with this API is, it only allows to save the model/summary based on some "time interval" but I need to do this based on "each step" of the training.

how to achieve this using TF-slim api.?

Here is the slim.learning train api -

def train(train_op,
          logdir,
          train_step_fn=train_step,
          train_step_kwargs=_USE_DEFAULT,
          log_every_n_steps=1,
          graph=None,
          master='',
          is_chief=True,
          global_step=None,
          number_of_steps=None,
          init_op=_USE_DEFAULT,
          init_feed_dict=None,
          local_init_op=_USE_DEFAULT,
          init_fn=None,
          ready_op=_USE_DEFAULT,
          summary_op=_USE_DEFAULT,
          **save_summaries_secs=600,**
          summary_writer=_USE_DEFAULT,
          startup_delay_steps=0,
          saver=None,
          **save_interval_secs=600,**
          sync_optimizer=None,
          session_config=None,
          session_wrapper=None,
          trace_every_n_steps=None,
          ignore_live_threads=False):

回答1:

Slim is deprecated, and using Estimator you get full control over saving / summary frequency.

You can also set the seconds to a very small number so it always saves.