Trains the model for a fixed number of epochs (iterations on a dataset). Arguments: x: Input data. It could be: - A Numpy array (or array-like), or a list of arrays (in case the model has multiple inputs). - A TensorFlow tensor, or a list of tensors
(self,
x=None,
y=None,
batch_size=None,
epochs=1,
verbose=1,
callbacks=None,
validation_split=0.,
validation_data=None,
shuffle=True,
class_weight=None,
sample_weight=None,
initial_epoch=0,
steps_per_epoch=None,
validation_steps=None,
validation_freq=1,
max_queue_size=10,
workers=1,
use_multiprocessing=False,
**kwargs)
| 532 | return training_arrays.ArrayLikeTrainingLoop() |
| 533 | |
| 534 | def fit(self, |
| 535 | x=None, |
| 536 | y=None, |
| 537 | batch_size=None, |
| 538 | epochs=1, |
| 539 | verbose=1, |
| 540 | callbacks=None, |
| 541 | validation_split=0., |
| 542 | validation_data=None, |
| 543 | shuffle=True, |
| 544 | class_weight=None, |
| 545 | sample_weight=None, |
| 546 | initial_epoch=0, |
| 547 | steps_per_epoch=None, |
| 548 | validation_steps=None, |
| 549 | validation_freq=1, |
| 550 | max_queue_size=10, |
| 551 | workers=1, |
| 552 | use_multiprocessing=False, |
| 553 | **kwargs): |
| 554 | """Trains the model for a fixed number of epochs (iterations on a dataset). |
| 555 | |
| 556 | Arguments: |
| 557 | x: Input data. It could be: |
| 558 | - A Numpy array (or array-like), or a list of arrays |
| 559 | (in case the model has multiple inputs). |
| 560 | - A TensorFlow tensor, or a list of tensors |
| 561 | (in case the model has multiple inputs). |
| 562 | - A dict mapping input names to the corresponding array/tensors, |
| 563 | if the model has named inputs. |
| 564 | - A `tf.data` dataset. Should return a tuple |
| 565 | of either `(inputs, targets)` or |
| 566 | `(inputs, targets, sample_weights)`. |
| 567 | - A generator or `keras.utils.Sequence` returning `(inputs, targets)` |
| 568 | or `(inputs, targets, sample weights)`. |
| 569 | y: Target data. Like the input data `x`, |
| 570 | it could be either Numpy array(s) or TensorFlow tensor(s). |
| 571 | It should be consistent with `x` (you cannot have Numpy inputs and |
| 572 | tensor targets, or inversely). If `x` is a dataset, generator, |
| 573 | or `keras.utils.Sequence` instance, `y` should |
| 574 | not be specified (since targets will be obtained from `x`). |
| 575 | batch_size: Integer or `None`. |
| 576 | Number of samples per gradient update. |
| 577 | If unspecified, `batch_size` will default to 32. |
| 578 | Do not specify the `batch_size` if your data is in the |
| 579 | form of symbolic tensors, datasets, |
| 580 | generators, or `keras.utils.Sequence` instances (since they generate |
| 581 | batches). |
| 582 | epochs: Integer. Number of epochs to train the model. |
| 583 | An epoch is an iteration over the entire `x` and `y` |
| 584 | data provided. |
| 585 | Note that in conjunction with `initial_epoch`, |
| 586 | `epochs` is to be understood as "final epoch". |
| 587 | The model is not trained for a number of iterations |
| 588 | given by `epochs`, but merely until the epoch |
| 589 | of index `epochs` is reached. |
| 590 | verbose: 0, 1, or 2. Verbosity mode. |
| 591 | 0 = silent, 1 = progress bar, 2 = one line per epoch. |