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

Method _model_iteration

tensorflow/python/keras/engine/training_v2.py:383–459  ·  view source on GitHub ↗
(
      self, model, mode, x=None, y=None, batch_size=None, verbose=1,
      sample_weight=None, steps=None, callbacks=None, max_queue_size=10,
      workers=1, use_multiprocessing=False, **kwargs)

Source from the content-addressed store, hash-verified

381 return model.history
382
383 def _model_iteration(
384 self, model, mode, x=None, y=None, batch_size=None, verbose=1,
385 sample_weight=None, steps=None, callbacks=None, max_queue_size=10,
386 workers=1, use_multiprocessing=False, **kwargs):
387
388 batch_size = model._validate_or_infer_batch_size(
389 batch_size, steps, x)
390 strategy = _get_distribution_strategy(model)
391 batch_size, steps = dist_utils.process_batch_and_step_size(
392 strategy, x, batch_size, steps, mode)
393 dist_utils.validate_callbacks(input_callbacks=callbacks,
394 optimizer=model.optimizer)
395 # Enter tf.distribute.Strategy scope.
396 with strategy.scope():
397 adapter = _process_inputs(
398 model,
399 x,
400 y,
401 batch_size=batch_size,
402 sample_weights=sample_weight,
403 steps=steps,
404 distribution_strategy=strategy,
405 max_queue_size=max_queue_size,
406 workers=workers,
407 use_multiprocessing=use_multiprocessing)
408 total_samples = _get_total_number_of_samples(adapter)
409 use_sample = total_samples is not None
410 dataset = adapter.get_dataset()
411
412 if not steps:
413 # Raise an error if `steps` isn't specified but the dataset
414 # is infinite.
415 steps = adapter.get_size() or training_utils.infer_steps_for_dataset(
416 model, dataset, steps, steps_name='steps')
417
418 # tf.print('{} on {} steps.'.format(ModeKeys.TRAIN, steps_per_epoch))
419 training_context = TrainingContext()
420 dataset = strategy.experimental_distribute_dataset(dataset)
421
422 execution_function = training_v2_utils._get_or_make_execution_function(
423 model, mode)
424
425 data_iterator = iter(dataset)
426
427 callbacks = cbks.configure_callbacks(
428 callbacks,
429 model,
430 do_validation=False,
431 batch_size=batch_size,
432 epochs=1,
433 steps_per_epoch=steps,
434 samples=use_sample,
435 count_mode='samples' if use_sample else 'steps',
436 verbose=0, # Handle ProgBarLogger separately in this loop.
437 mode=mode)
438
439 with training_context.on_start(
440 model, callbacks, use_sample, verbose, mode):

Callers 2

evaluateMethod · 0.95
predictMethod · 0.95

Calls 14

on_startMethod · 0.95
on_epochMethod · 0.95
_process_inputsFunction · 0.85
TrainingContextClass · 0.85
run_one_epochFunction · 0.85
reset_metricsMethod · 0.80
scopeMethod · 0.45
get_datasetMethod · 0.45
get_sizeMethod · 0.45

Tested by

no test coverage detected