On this web page, we will show how to use Real Statistics’ Training a Neural Network data analysis tool to train the neural network for Example 1 of Simple Neural Network Example. We will also use the Testing a Neural Network to determine the accuracy of the network.
Dialog Box
This is done by pressing Ctrl-m and choosing Training a Neural Network from the Corr tab. Fill in the dialog box that appears as shown in Figure 1.
Figure 1 – Training a Neural Network dialog box
We specify the location of the training data (in Input Range); the number of nodes in the Input, Hidden, and Output layers; as well as the learning rate and mini-batch size (4 since we want to use all the training data). Since we have inserted a zero in the Initialization Range field, the biases will be initialized to -1 and the weights to +1.
We have also set the Epochs field to 0. This will result in output based solely on the initial biases and weights (i.e. no backward propagation will be used).
Initial output
The output is shown in Figure 2.
Figure 2 – Output showing initial biases and weights
In this figure, we see the biases and weights assigned when the Initialization Range field is set to 0. We also see that the cost for this configuration is shown in cell F4.
Continuing the training
We can continue training the neural network from these biases and weights, but since we want to duplicate the results from Example 1 of Simple Neural Network Example, we will set the initial weights to those used in range A10:I10 of Figure 3 of Simple Neural Network Example. This is shown on the left side of Figure 3.
Figure 3 – Using the new initial values
We have simply written in the biases and weights from range F7:F17 in Figure 2. We can now rerun the Training of a Neural Network data analysis tool, except that this time we will want to fill in the Initialization Range field with cell F7 which now contains the first cell of the range that contains the initial values that we want to use. This range must be formatted as shown in F7:F17 (namely output layer biases/weights, two empty cells, followed by the hidden layer biases/weights).
We also specify Epochs to be 20. After clicking on the OK button, the results shown in Figure 4 appear.
Figure 4 – Output from Training a Neural Network
The output contains the new biases and weights after 20 epochs (range H6:I17). These should agree with the values shown in Figure 7 of Simple Neural Network Example. The output also shows that the cost function is 0.083544, which also agrees with the values shown in Figure 7 of Simple Neural Network Example, Finally, the output also contains a history of the cost function for each of the 20 epochs. This information can be useful in determining how to continue training.
Testing the results
We have now trained the neural network, but we still need to see whether the training has been successful. To do this, we need to see how well the neural network does on some test data. For this simple case, we can only use the original training data as our test data (since there aren’t any more cases).
This is done by pressing Ctrl-m and selecting the Testing a Neural Network data analysis tool from the Corr tab. We fill in the dialog box as shown on the right side of Figure 5. Note that we fill in the Biases/Weights Range with cell I7, namely the first cell from the output from Figure 4. After pressing the OK button, the output shown on the left side of Figure 5 appears.
Figure 5 – Testing the Neural Network
We see the same results in range N4:N7 as those shown in range S130:S133 of Figure 7 of Simple Neural Network Example. Mapping values in column N less than .5 to 0 and values greater than .5 to 1, we get the desired results as shown in column O.
Examples Workbook
Click here to download the Excel workbook with the examples described on this webpage.
References
Lubick, K. (2022) Training a neural network in a spreadsheet
https://www.youtube.com/watch?v=fjfZZ6S1ad4
https://www.youtube.com/watch?v=1zwnPt73pow
Nielson, M. (2019) Neural networks and deep learning
http://neuralnetworksanddeeplearning.com/
Drea Dr, good evening I think there is mistake when you us Testing a Neural Network, I was replaying the example but teh bias, I have a error, please could you review that case?
Thak you very much.
Oh Doc excuseme , I was not selecting the full column of bias and weiths .
Thank you
Gerardo,
Glad to see that you worked it out.
Charles