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

Method _call_batch_hook

tensorflow/python/keras/callbacks.py:221–245  ·  view source on GitHub ↗

Helper function for all batch_{begin | end} methods.

(self, mode, hook, batch, logs=None)

Source from the content-addressed store, hash-verified

219 callback.set_model(model)
220
221 def _call_batch_hook(self, mode, hook, batch, logs=None):
222 """Helper function for all batch_{begin | end} methods."""
223 if not self.callbacks:
224 return
225 hook_name = 'on_{mode}_batch_{hook}'.format(mode=mode, hook=hook)
226 if hook == 'begin':
227 self._t_enter_batch = time.time()
228 if hook == 'end':
229 # Batch is ending, calculate batch time.
230 self._delta_t_batch = time.time() - self._t_enter_batch
231
232 logs = logs or {}
233 t_before_callbacks = time.time()
234 for callback in self.callbacks:
235 batch_hook = getattr(callback, hook_name)
236 batch_hook(batch, logs)
237 self._delta_ts[hook_name].append(time.time() - t_before_callbacks)
238
239 delta_t_median = np.median(self._delta_ts[hook_name])
240 if (self._delta_t_batch > 0. and
241 delta_t_median > 0.95 * self._delta_t_batch and delta_t_median > 0.1):
242 logging.warning(
243 'Method (%s) is slow compared '
244 'to the batch update (%f). Check your callbacks.', hook_name,
245 delta_t_median)
246
247 def _call_begin_hook(self, mode):
248 """Helper function for on_{train|test|predict}_begin methods."""

Callers 14

on_batch_beginMethod · 0.95
on_batch_endMethod · 0.95
on_train_batch_beginMethod · 0.95
on_train_batch_endMethod · 0.95
on_test_batch_beginMethod · 0.95
on_test_batch_endMethod · 0.95
on_predict_batch_endMethod · 0.95
model_iterationFunction · 0.80

Calls 3

timeMethod · 0.80
formatMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected