MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / configure_callbacks

Function configure_callbacks

tensorflow/python/keras/callbacks.py:60–119  ·  view source on GitHub ↗

Configures callbacks for use in various training loops. Arguments: callbacks: List of Callbacks. model: Model being trained. do_validation: Whether or not validation loop will be run. batch_size: Number of samples per batch. epochs: Number of epoch to train. st

(callbacks,
                        model,
                        do_validation=False,
                        batch_size=None,
                        epochs=None,
                        steps_per_epoch=None,
                        samples=None,
                        verbose=1,
                        count_mode='steps',
                        mode=ModeKeys.TRAIN)

Source from the content-addressed store, hash-verified

58
59
60def configure_callbacks(callbacks,
61 model,
62 do_validation=False,
63 batch_size=None,
64 epochs=None,
65 steps_per_epoch=None,
66 samples=None,
67 verbose=1,
68 count_mode='steps',
69 mode=ModeKeys.TRAIN):
70 """Configures callbacks for use in various training loops.
71
72 Arguments:
73 callbacks: List of Callbacks.
74 model: Model being trained.
75 do_validation: Whether or not validation loop will be run.
76 batch_size: Number of samples per batch.
77 epochs: Number of epoch to train.
78 steps_per_epoch: Number of batches to run per training epoch.
79 samples: Number of training samples.
80 verbose: int, 0 or 1. Keras logging verbosity to pass to ProgbarLogger.
81 count_mode: One of 'steps' or 'samples'. Per-batch or per-sample count.
82 mode: String. One of ModeKeys.TRAIN, ModeKeys.TEST, or ModeKeys.PREDICT.
83 Which loop mode to configure callbacks for.
84
85 Returns:
86 Instance of CallbackList used to control all Callbacks.
87 """
88 # Check if callbacks have already been configured.
89 if isinstance(callbacks, CallbackList):
90 return callbacks
91
92 if not callbacks:
93 callbacks = []
94
95 # Add additional callbacks during training.
96 if mode == ModeKeys.TRAIN:
97 model.history = History()
98 callbacks = [BaseLogger()] + (callbacks or []) + [model.history]
99 if verbose:
100 callbacks.append(ProgbarLogger(count_mode))
101 callback_list = CallbackList(callbacks)
102
103 # Set callback model
104 callback_model = model._get_callback_model() # pylint: disable=protected-access
105 callback_list.set_model(callback_model)
106
107 set_callback_parameters(
108 callback_list,
109 model,
110 do_validation=do_validation,
111 batch_size=batch_size,
112 epochs=epochs,
113 steps_per_epoch=steps_per_epoch,
114 samples=samples,
115 verbose=verbose,
116 mode=mode)
117

Callers

nothing calls this directly

Calls 8

set_modelMethod · 0.95
HistoryClass · 0.85
BaseLoggerClass · 0.85
ProgbarLoggerClass · 0.85
CallbackListClass · 0.85
set_callback_parametersFunction · 0.85
_get_callback_modelMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected