Fit - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

DeepLearning/Model/Fit

fit model object to training data

 Calling Sequence mdl:-Fit(x, y, opts)

Parameters

 mdl - a Model object x - list, Array, DataFrame, DataSeries, Matrix, or Vector; input data y - list, Array, DataFrame, DataSeries, Matrix, or Vector; target data

Options

 • batchsize = posint or none
 Number of samples per gradient update. If unspecified, batchsize will default to 32.
 • epochs  = nonnegint
 Number of epochs to train the model. An epoch is an iteration over the entire x and y data provided.
 The model is not trained for a number of iterations given by epochs, but merely until the epoch of index epochs is reached.
 • shuffle = truefalse
 Whether or not to reshuffle the training data before each epoch.

Description

 • Fit trains a Model on data for a fixed number of epochs.

Details

 • The implementation of Fit uses the fit method from tf.keras.Model in the TensorFlow Python API. Consult the TensorFlow Python API documentation for tf.keras.Model for more information on its use during TensorFlow computations.

Examples

 > $\mathrm{with}\left(\mathrm{DeepLearning}\right)$
 $\left[{\mathrm{AddMultiple}}{,}{\mathrm{ApplyOperation}}{,}{\mathrm{BatchNormalizationLayer}}{,}{\mathrm{BidirectionalLayer}}{,}{\mathrm{BucketizedColumn}}{,}{\mathrm{CategoricalColumn}}{,}{\mathrm{Classify}}{,}{\mathrm{Concatenate}}{,}{\mathrm{Constant}}{,}{\mathrm{ConvolutionLayer}}{,}{\mathrm{DNNClassifier}}{,}{\mathrm{DNNLinearCombinedClassifier}}{,}{\mathrm{DNNLinearCombinedRegressor}}{,}{\mathrm{DNNRegressor}}{,}{\mathrm{Dataset}}{,}{\mathrm{DenseLayer}}{,}{\mathrm{DropoutLayer}}{,}{\mathrm{EinsteinSummation}}{,}{\mathrm{EmbeddingLayer}}{,}{\mathrm{Estimator}}{,}{\mathrm{FeatureColumn}}{,}{\mathrm{Fill}}{,}{\mathrm{FlattenLayer}}{,}{\mathrm{GRULayer}}{,}{\mathrm{GatedRecurrentUnitLayer}}{,}{\mathrm{GetDefaultGraph}}{,}{\mathrm{GetDefaultSession}}{,}{\mathrm{GetEagerExecution}}{,}{\mathrm{GetVariable}}{,}{\mathrm{GradientTape}}{,}{\mathrm{IdentityMatrix}}{,}{\mathrm{LSTMLayer}}{,}{\mathrm{Layer}}{,}{\mathrm{LinearClassifier}}{,}{\mathrm{LinearRegressor}}{,}{\mathrm{LongShortTermMemoryLayer}}{,}{\mathrm{MaxPoolingLayer}}{,}{\mathrm{Model}}{,}{\mathrm{NumericColumn}}{,}{\mathrm{OneHot}}{,}{\mathrm{Ones}}{,}{\mathrm{Operation}}{,}{\mathrm{Optimizer}}{,}{\mathrm{Placeholder}}{,}{\mathrm{RandomTensor}}{,}{\mathrm{ResetDefaultGraph}}{,}{\mathrm{Restore}}{,}{\mathrm{Save}}{,}{\mathrm{Sequential}}{,}{\mathrm{Session}}{,}{\mathrm{SetEagerExecution}}{,}{\mathrm{SetRandomSeed}}{,}{\mathrm{SoftMaxLayer}}{,}{\mathrm{SoftmaxLayer}}{,}{\mathrm{Tensor}}{,}{\mathrm{Variable}}{,}{\mathrm{Variables}}{,}{\mathrm{VariablesInitializer}}{,}{\mathrm{Zeros}}\right]$ (1)
 > $\mathrm{v1}≔\mathrm{Vector}\left(8,i→i,\mathrm{datatype}={\mathrm{float}}_{8}\right)$
 ${\mathrm{v1}}{≔}\left[\begin{array}{c}{1.}\\ {2.}\\ {3.}\\ {4.}\\ {5.}\\ {6.}\\ {7.}\\ {8.}\end{array}\right]$ (2)
 > $\mathrm{v2}≔\mathrm{Vector}\left(8,\left[-1.0,1.0,5.0,11.0,19.0,29.0,41.0,55.0\right],\mathrm{datatype}={\mathrm{float}}_{8}\right)$
 ${\mathrm{v2}}{≔}\left[\begin{array}{c}{-1.}\\ {1.}\\ {5.}\\ {11.}\\ {19.}\\ {29.}\\ {41.}\\ {55.}\end{array}\right]$ (3)
 > $\mathrm{model}≔\mathrm{Sequential}\left(\left[\mathrm{DenseLayer}\left(1,\mathrm{inputshape}=\left[1\right]\right)\right]\right)$
 ${\mathrm{model}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Model}}\\ {\mathrm{}}\end{array}\right]$ (4)
 > $\mathrm{model}:-\mathrm{Compile}\left(\mathrm{optimizer}="sgd",\mathrm{loss}="mean_squared_error"\right)$
 > $\mathrm{model}:-\mathrm{Fit}\left(\mathrm{v1},\mathrm{v2},\mathrm{epochs}=500\right)$
 ${">"}$ (5)
 > $\mathrm{model}:-\mathrm{Evaluate}\left(\left[10\right],\left[30\right]\right)$
 $\left\{{"loss"}{=}{1038.93322753906}{,}{"accuracy"}{=}{0.}\right\}$ (6)

Compatibility

 • The DeepLearning/Model/Fit command was introduced in Maple 2021.
 • For more information on Maple 2021 changes, see Updates in Maple 2021.