Gradient Calculation of a Fully Connected Neural Network Lab for Binary Classification

(Zongcai Feng)


PIC

1 Objective: Generate binary training set of vectors that contain 1s and 0s. Classify which ones only contain only 0 (class=1) or not (class=0). Use multilayer neural network that requires the input of parameters to set up the FNN structure. Validate the accuracy of the NN gradient using a finite -difference approximation to the gradient.

2 Prerequisties

  • Matlab
  • Knowledge of Fully Connected Neural Network Lab (> 3 Procedure
    1. Download the codes ./Chapter.Gradient.Neural.zip and unzip it.
    2. Change your Matlab working directory to "Chapter.Gradient.Neural" while in MATLAB and follow the instruction to input your setting of parameters. Results will be displayed for the predicted classes.
    3. Type NNode_test.m to generate plots similar to Figure 4.25 in Schuster et al. (2021) book. These results are for 2-layer network. Adjust code to be a 2-layer network with more hidden nodes, and rerun adjusted code. Are the errors still small?
    4. PIC

    5. Type NNode1.m to generate plots similar to Figure 14.4 in Schuster et al. (2021) book. These results are for 2-layer network with nodes/layer [5 1 1] and ReLU activation functions and a cross-entropy misfit function. Adjust parameters so that the hidden activation function is a sigmoid and the misfit is L2; rerun code.
    6. PIC

      Figure 3. Results similar to to Figure 4.14 in Schuster et al. (2021) using the neural network with two layers. The notation [5 10 1] indicates that the input example is a 5×1 vector and layers 1 and 2 each have ten nodes and one node, respectively.