Skip to content
Snippets Groups Projects
Commit bda06e60 authored by Saidi Aya's avatar Saidi Aya
Browse files

Update mlp.py

parent 06f5ead5
No related branches found
No related tags found
No related merge requests found
import numpy as np import numpy as np
import matplotlib.pyplot as plt
import math
import random
from read_cifar import *
#We are using the segmoid activation function #We are using the segmoid activation function
def segmoid(x): def segmoid(x):
return 1/(1+np.exp(-x)) return 1/(1+np.exp(-x))
...@@ -19,7 +23,7 @@ def learn_once_mse(w1,b1,w2,b2,data,targets,learning_rate): ...@@ -19,7 +23,7 @@ def learn_once_mse(w1,b1,w2,b2,data,targets,learning_rate):
A2=segmoid(np.matmul(A1,w2) + b2) A2=segmoid(np.matmul(A1,w2) + b2)
#Let calculate the partial derivates #Let calculate the partial derivates
#2 #2
D_A2=2*(A2-tragets) D_A2=2*(A2-targets)
D_A2_T=np.matmul(A2,(1-A2).T) D_A2_T=np.matmul(A2,(1-A2).T)
D_Z2=np.matmul(D_A2_T,D_A2) D_Z2=np.matmul(D_A2_T,D_A2)
D_W2=np.matmul(A1.T,D_Z2) D_W2=np.matmul(A1.T,D_Z2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment