Question
Q-Consider the MLP provided below with two inputs, two hidden neurons and two output neurons. Additionally, the hidden and output neurons include a bias term
Q-Consider the MLP provided below with two inputs, two hidden neurons and two output neurons. Additionally, the hidden and output neurons include a bias term each (b1 and b2). Given the input values (e.g., x1 = 0.10 and x2 = 0.20), we want the neural network to output corresponding values (e.g., o1 = 0.10 and o2 = 0.90). The network structure is fixed, and squared error function should be used for error calculation. Assume sigmoid activation functions in the hidden and output layers.
(i) Implement the forward pass routine of the backpropagation algorithm which outputs the error associated with any weight selection in the network. Sample function call and expected outputs are provided below.
# v_initW_l1 and v_initW_l2 values are network weights for the first and second layer, respectively, and they are provided in hw1_q4_helper.py # v_inputs and v_targetOutputs are network input and output, respectively, and they are provided in hw1_q4_helper.py v_out_h,v_out=ForwardPass(v_inputs, v_initW_l1, v_initW_l2, v_targetOutputs) # v_out_h: output values for the hidden units # v_out: output values for the output units print("v_out_h", v_out_h) # [0.5866 0.5903 1. ] print("v_out", v_out) # [0.7351 0.7465]]
(ii) Following from part (i), implement the backw: ard pass routine of the backpropagation algorithm which outputs the updated weight values for the network. Sample function call and expected outputs are provided below.
t_v_updatedW_l1, t_v_updatedW_l2 = BackwardPass(v_inputs, v_initW_l1, v_initW_l2, v_targetOutputs, geta=0.5) # geta: learning rate # t_v_updatedW_l1, t_v_updatedW_l2: updated weight values for layer 1 and 2 print(t_v_updatedW_l1) [[0.0997 0.1496] [0.1993 0.2491] [0.2967 0.2956]] print(t_v_updatedW_l2) [[0.3137 0.4085] [0.4135 0.5086] [0.4882 0.5645]]
0.10Step 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