If you have not already completed it, it is time, now, to
do Problem 2 of Tutorial 5.
So that you have a data type Layer
to handle
one individual layer (hidden or output) in the neural network.
Define a data type Network
for the neural network,
consisting of a list of layers.
Look up the weights used to solve the XOR problem in Marsland's book. Define the three neurons with appropriate weights, and define the network assembling the three nodes.
Test your definition by evaluating it in GHCi.
Having completed Problem 2 of Tutorial 5 previously, you have a recall function for a single layer. Now, we need the following recall function for a neural network.
recallNetwork :: Network -> InputVector -> OutputValue
This function will need to do recall for the first layer in
the network (list of layers). The output from the recall of
the first layer is used as input for recall in the second
layer. This continues throughout the list, and the output
from the last layer is the output of recallNetwork
.
Implement recallNetwork
.
Finally, test your definitions with the following evaluations:
recallNetwork xorNetwork [0,0]
recallNetwork xorNetwork [0,1]
recallNetwork xorNetwork [1,0]
recallNetwork xorNetwork [1,1]
There are two common sources of errors in this network/implementation.