Tensorflow.js tf.LayersModel class .fitDataset() Method
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. Tensorflow.js tf.LayersModel class .fitDataset() method is used to trains the layer model by using a dataset object.
Parameters: This method accepts the following parameters:
- dataset: It is an input value in the form of the dataset by which we train our layer model.
- args: It Is an object that contains the following values:
- batchesPerEpoch: It is the number of batches in every epoch. It depends on the size of the batch as batch size increases its size decreases.
- epochs: It is the total number of iteration in the training dataset during the training model. It should be an integer value.
- initialEpoch: It is used to define the epoch’s value at which to start training.
- validationData: It is used to give an estimate of the final model when selecting between final models.
- verbose: It help in showing the progress for each epoch. If the value is 0 – It means no printed message during fit() call. If the value is 1 – It means in Node.js, it prints the progress bar. In the browser, it shows no action. Value 1 is the default value . 2 – Value 2 is not implemented yet.
- classWeight: It is used for weighting the loss function. It can be useful to tell the model to pay more attention to samples from an under-represented class.
- callbacks: It defines a list of callbacks to be called during training. Variable can have one or more of these callbacks onTrainBegin( ), onTrainEnd( ), onEpochBegin( ), onEpochEnd( ), onBatchBegin( ), onBatchEnd( ), onYield( ).
- validationBatchSize: It is the number that defines the size of the batch. It is used to validate the batch size. It means that we can’t put all datasets at once that exceeding this value. its defaults value is 32.
- validationBatches: It is used to validate the batches of samples. It is used to draw validation data for validation purposes at every end of an epoch.
- yieldEvery: It defines the configuration of the frequency of yielding the main thread to other tasks. It can be auto, It means the yielding happens at a certain frame rate. batch, If the value is this, It yields every batch. epoch, If the value is this, It yields every epoch. any number, If the value is any number, it yields every number milliseconds. never, If the value is this, it never yields.
Returns: Promise< History >
Example 1: In this example, we will train our layer model with CSV dataset.
41480.109375 28887.93359375 20162.228515625 14115.478515625 9924.9404296875 7020.56005859375
Example 2: In this example, we will train our layer model with a dataset of the array.
Loss After Training Layer Model 4.386415958404541