Network training

To begin training, we need to configure a dataset object first. The mini-batch size can be automatically configured when we define the dataset object. In this example, this happens when we create the RegressionDataset type object.

To perform one training step, we should use the step method of the optimizer object, but we should be aware that this method does only one pass of mini-batch training. So, to perform several epochs using the whole dataset, we have to manually calculate the number of steps.

When training is done, we have to copy the trained parameters from the optimizer object to the network object. This can be done with the setParameterVector method of the network object. We can use the solution() method to get parameters from the optimizer.

Now that we've described all the required components, let's look at the complete programming sample.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.189.228