Loss function definition

After we've defined the network structure, we need to define the loss function for the optimization algorithm. The ErrorFunction class is used for this purpose. Its constructor takes four parameters:

  • An object representing the training dataset
  • A pointer to the object that represents the network's structure
  • A pointer to the object that implements the loss function—SquaredLoss, in our case
  • A Boolean flag telling us to use mini-batches or not

The ErrorFunction type object can be configured with a regularizer. For example, we can instantiate the object of the TwoNormRegularizer class and call the setRegularizer method in the ErrorFunction type object with two parameters: the weight decay factor value and the pointer to the regularizer object. To finish the configuration of the ErrorFunction type object, we need to call the init method.

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

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