Requirements: step
The training data is the set of 4 letters (r,i,c,e) given in the arrays above. Write a code that performs maxiter iterations of the gradient descent. Let the user set the learning parameter (gammaval). Your code will compute the loss function, the partial derivatives of the loss function with respect to V and W. The code below shows how to initialize the matrices V and W with the same random seed. Test the code with maxiter=2000 and gammaval=0.1. Print the loss function at the end of all the gradient descent iterations. Check the code is correct by writing a small code that produces a prediction from an input that belongs to the training dataset (this can be defined as a function so that we can reuse it). We should recover exact prediction if the training has been done correctly. Finally, choose the letter r and perform 100 perturbations of letter r, using the function mod. For a given perturbation, apply the neural network to obtain a prediction. Count each time the prediction is good. Display the final number of good predictions (should be equal to 100: perfect score). Code np.random.seed(0) Vmat=np.random.standard_normal(size=(25,25)) np.random.seed(0) Wmat=np.random.standard_normal(size=(2,25))
The post Neural Network, Python first appeared on Bessays.
Need help with your own assignment?
Our expert writers can help you apply everything you've just read — to your actual assignment.
Get Expert Help Now →