Neural Network with Feed Forward
So we have created linear layers and activation functions with forward methods. Our final class
will be to create a NeuralNet
which will contain everything it needs and provide an API to the user.
We will follow the Scikit-Learner API style for this. So there will be a predict
method and a fit
method (let's not worry about all other utility methods for now). As we have just implemented the forward methods for all the classes, let's create the predict
method using those forward
methods of all classes.
PYTHON
1class NeuralNet():
2 def __init__(self, layers=[]):
3 self.layers = layers
4
5 def predict(X):
6 for layer in layers:
7 A = layer.forward(A)
8 return A
This looks easy, right? But now we will implement a little difficult part of the NeuralNet. The Backward Propagation.