class_docstr: Separately save the model with minimum value of some statistics.
class_docstr_tok: ["Separately","save","the","model","with","minimum","value","of","some","statistics","."]
docstr: Args:
      monitor_stat(str): the name of the statistics.
      reverse (bool): if True, will save the maximum.
      filename (str): the name for the saved model.
          Defaults to ``min-{monitor_stat}.tfmodel``.
      checkpoint_dir (str): the directory containing checkpoints.
  
  Example:
      Save the model with minimum validation error to
      "min-val-error.tfmodel":
  
      .. code-block:: python
  
          MinSaver('val-error')
  
  Note:
      1. It assumes that :class:`ModelSaver` is used with the same ``checkpoint_dir``
         and appears earlier in the callback list.
         The default for both :class:`ModelSaver` and :class:`MinSaver`
         is ``checkpoint_dir=logger.get_logger_dir()``
      2. Callbacks are executed in the order they are defined. Therefore you'd want to
         use this callback after the callback (e.g. InferenceRunner) that produces the statistics.
docstr_tok: ["Args",":","monitor_stat","(","str",")",":","the","name","of","the","statistics",".","reverse","(","bool",")",":","if","True",",","will","save","the","maximum",".","filename","(","str",")",":","the","name","for","the","saved","model",".","Defaults","to","``","min-","{","monitor_stat","}",".tfmodel","``",".","checkpoint_dir","(","str",")",":","the","directory","containing","checkpoints",".","Example",":","Save","the","model","with","minimum","validation","error","to","``","min-val-error.tfmodel","''",":","..","code-block",":",":","python","MinSaver","(","'val-error","'",")","Note",":","1",".","It","assumes","that",":","class",":","`","ModelSaver","`","is","used","with","the","same","``","checkpoint_dir","``","and","appears","earlier","in","the","callback","list",".","The","default","for","both",":","class",":","`","ModelSaver","`","and",":","class",":","`","MinSaver","`","is","``","checkpoint_dir=logger.get_logger_dir","(",")","``","2",".","Callbacks","are","executed","in","the","order","they","are","defined",".","Therefore","you","'d","want","to","use","this","callback","after","the","callback","(","e.g",".","InferenceRunner",")","that","produces","the","statistics","."]
code: def __init__(
      self,
      monitor_stat,
      reverse=False,
      filename=None,
      checkpoint_dir=None,
  ):
      """
      Args:
          monitor_stat(str): the name of the statistics.
          reverse (bool): if True, will save the maximum.
          filename (str): the name for the saved model.
              Defaults to ``min-{monitor_stat}.tfmodel``.
          checkpoint_dir (str): the directory containing checkpoints.
  
      Example:
          Save the model with minimum validation error to
          "min-val-error.tfmodel":
  
          .. code-block:: python
  
              MinSaver('val-error')
  
      Note:
          1. It assumes that :class:`ModelSaver` is used with the same ``checkpoint_dir``
             and appears earlier in the callback list.
             The default for both :class:`ModelSaver` and :class:`MinSaver`
             is ``checkpoint_dir=logger.get_logger_dir()``
          2. Callbacks are executed in the order they are defined. Therefore you'd want to
             use this callback after the callback (e.g. InferenceRunner) that produces the statistics.
      """
      self.monitor_stat = monitor_stat
      self.reverse = reverse
      self.filename = filename
      self.best = None
      self.checkpoint_dir = checkpoint_dir
      if self.checkpoint_dir is None:
          self.checkpoint_dir = logger.get_logger_dir()
      self.checkpoint_dir = fs.normpath(self.checkpoint_dir)
  
file_path: tensorpack/tensorpack/callbacks/saver.py
imports: import os
  from datetime import datetime
  from ..compat import tfv1
  from ..utils import fs, logger
  from .base import Callback
label_desc: Use image node_id 1 to create a new MinSaver object from inherited base classes: Callback with example: obj = MinSaver(monitor_stat, reverse, filename, checkpoint_dir)