jonbakerfish commented on issue #658: Checkpoint every some iterations
URL: https://github.com/apache/incubator-mxnet/issues/658#issuecomment-329798467
 
 
   FYI: a checkpoint class for `batch_end_callback`:
   
       class BatchCheckpoint(object):
           def __init__(self, mod, prefix, period, save_optimizer_states=False):
               """checkpoint for batch_end_callback
   
               Parameters
               ----------
               mod : subclass of BaseModule
                   The module to checkpoint.
               prefix : str
                   The file prefix for this checkpoint.
               period : int
                   How many batchs to wait before checkpointing.
               save_optimizer_states : bool
                   Indicates whether or not to save optimizer states for 
continued training.
   
               Example
               -------
               >>> # save checkpoint every ten batches.
               >>> module.fit(iterator, num_epoch=n_epoch,
               ... batch_end_callback=callback.BatchCheckpoint(module, prefix, 
10))
               """
               self.mod = mod
               self.prefix = prefix
               self.period = period
               self.save_optimizer_states = save_optimizer_states
   
           def __call__(self, param):
               if (param.nbatch + 1) % self.period == 0:
                   self.mod.save_checkpoint(self.prefix + 
'-e-%04d-b'%param.epoch, 
                                            param.nbatch + 1, 
self.save_optimizer_states)
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to