通过检查 tf.keras.models.Model 的 fit 方法中的代码,可以逐渐定位到下面这段代码:
for step_index in range (steps_per_epoch):
batch_logs = {}
batch_logs ['batch'] = step_index
batch_logs ['size'] = 1
callbacks.on_batch_begin (step_index, batch_logs)
try:
outs = f (ins)
except errors.OutOfRangeError:
logging.warning ('Your dataset iterator ran out of data; '
'interrupting training. Make sure that your dataset '
'can generate at least `steps_per_epoch * epochs` '
'batches (in this case, %d batches).' %
steps_per_epoch * epochs)
break
if not isinstance (outs, list):
outs = [outs]
for l, o in zip (out_labels, outs):
batch_logs [l] = o
callbacks.on_batch_end (step_index, batch_logs)
if callback_model.stop_training:
break