MCPcopy Index your code
hub / github.com/tensorflow/models / __init__

Method __init__

orbit/controller.py:94–255  ·  view source on GitHub ↗

Initializes a `Controller` instance. Note that if `checkpoint_manager` is provided and there are checkpoints in the associated model directory, the model will be restored from the most recent checkpoint during this `__init__` method. Args: global_step: An integer `tf.Variable

(
      self,
      *,  # Makes all args keyword only.
      global_step: tf.Variable,
      trainer: Optional[runner.AbstractTrainer] = None,
      evaluator: Optional[runner.AbstractEvaluator] = None,
      strategy: Optional[tf.distribute.Strategy] = None,
      # Actions
      train_actions: Optional[Iterable[Action]] = None,
      eval_actions: Optional[Iterable[Action]] = None,
      # Train related
      steps_per_loop: Optional[Union[int, Callable[[int], int]]] = None,
      checkpoint_manager: Optional[tf.train.CheckpointManager] = None,
      enable_async_checkpointing: bool = False,
      # Summary related
      summary_interval: Optional[int] = None,
      summary_dir: Optional[str] = None,
      # Evaluation related
      eval_summary_dir: Optional[str] = None,
      summary_manager: Optional[utils.SummaryManagerInterface] = None,
      eval_summary_manager: Optional[utils.SummaryManagerInterface] = None)

Source from the content-addressed store, hash-verified

92 """
93
94 def __init__(
95 self,
96 *, # Makes all args keyword only.
97 global_step: tf.Variable,
98 trainer: Optional[runner.AbstractTrainer] = None,
99 evaluator: Optional[runner.AbstractEvaluator] = None,
100 strategy: Optional[tf.distribute.Strategy] = None,
101 # Actions
102 train_actions: Optional[Iterable[Action]] = None,
103 eval_actions: Optional[Iterable[Action]] = None,
104 # Train related
105 steps_per_loop: Optional[Union[int, Callable[[int], int]]] = None,
106 checkpoint_manager: Optional[tf.train.CheckpointManager] = None,
107 enable_async_checkpointing: bool = False,
108 # Summary related
109 summary_interval: Optional[int] = None,
110 summary_dir: Optional[str] = None,
111 # Evaluation related
112 eval_summary_dir: Optional[str] = None,
113 summary_manager: Optional[utils.SummaryManagerInterface] = None,
114 eval_summary_manager: Optional[utils.SummaryManagerInterface] = None):
115 """Initializes a `Controller` instance.
116
117 Note that if `checkpoint_manager` is provided and there are checkpoints in
118 the associated model directory, the model will be restored from the most
119 recent checkpoint during this `__init__` method.
120
121 Args:
122 global_step: An integer `tf.Variable` storing the global training step
123 number. Usually this can be obtained from the `iterations` property of
124 the model's optimizer (e.g. `trainer.optimizer.iterations`). In cases
125 where multiple optimizers are used, or if one model "step" corresponds
126 to more than one update to model parameters, users can create and
127 increment their own global step variable as well. In this case it is
128 recommended to create the `tf.Variable` inside the distribution strategy
129 scope, with `aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA` (see
130 also `orbit.utils.create_global_step()`).
131 trainer: An instance of `orbit.AbstractTrainer`, which implements the
132 inner training loop.
133 evaluator: An instance of `orbit.AbstractEvaluator`, which implements
134 evaluation.
135 strategy: An instance of `tf.distribute.Strategy`. If not provided, the
136 strategy will be initialized from the current in-scope strategy using
137 `tf.distribute.get_strategy()`.
138 train_actions: Optional `orbit.Action`s to call after each block of
139 `steps_per_loop` training steps are run. These will be called with the
140 output of `trainer.train`.
141 eval_actions: Optional `orbit.Action`s to call after each evaluation.
142 These will be called with the output of `evaluator.evaluate`.
143 steps_per_loop: Optional integer to indicate the number of steps to run in
144 each inner loop of training (passed as the `num_steps` parameter of
145 `trainer.train`). It can be also a callable which takes the current
146 global step value as input and returns the number of steps to run as
147 output.
148 checkpoint_manager: An instance of `tf.train.CheckpointManager`. If
149 provided and there are checkpoints in the associated model directory,
150 the model will be restored from the most recent checkpoint inside this
151 `__init__` method. If not provided, the `Controller` will not

Callers

nothing calls this directly

Calls 3

restore_checkpointMethod · 0.95
_logFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected