Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please fill in the question marks and DO NOT ALTER / DELETE EXISTING CODE OR ADD ANY NEW LINES OF CODE!!!!!!!!!: # Define the activation
Please fill in the question marks and DO NOT ALTERDELETE EXISTING CODE OR ADD ANY NEW LINES OF CODE!!!!!!!!!: # Define the activation function.
sigma nptanh
# Let's use a random initial weight and bias.
W nparray
b nparray
# define our feed forward function
def aa :
# Notice the next line is almost the same as previously,
# except we are using matrix multiplication rather than scalar multiplication
z npdotW a b
# Everything else is the same though,
return sigmaz
# Next, if a training example is
x nparray
y nparray
# Then the cost function is
d ax y # Vector difference between observed and expected activation
C npsumd # Absolute value squared of the difference.
sigma nptanh
# Next define the feedforward equation.
def aw b a :
z npdotw a b
return sigmaz
# This function returns the derivative of the cost function with
# respect to the weight.
def dCdw w a b x y :
a alwl bl x
dCda a y # Derivative of cost with activation
dadz nptanha # derivative of activation with weighted sum z
J dCda dadz
dzdw x # derivative of weighted sum z with weight
J dCda dadz
return J # Return the chain rule product.
# This function returns the derivative of the cost function with
# respect to the bias.
# It is very similar to the previous function.
# You should complete this function.
def dCdb w b x y :
dCda a y
dadz nptanha
# Change the next line to give the derivative of
# the weighted sum, z with respect to the bias, b
dzdb
return dCda dadz dzdb
#the code must work with this statement: dCdb W b x y
arraye
e
dCdw W b x y
arrayeee
eee PLEASE ENSURE THERE ARE NO ERRORS SUCH AS : NameError: name a is not defined.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started