Task 1: Initialise Parameters In the cell below you must define a function to initialise the weight matrices for each la

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Task 1: Initialise Parameters In the cell below you must define a function to initialise the weight matrices for each la

Post by answerhappygod »

Task 1 Initialise Parameters In The Cell Below You Must Define A Function To Initialise The Weight Matrices For Each La 1
Task 1 Initialise Parameters In The Cell Below You Must Define A Function To Initialise The Weight Matrices For Each La 1 (55.64 KiB) Viewed 44 times
Task 1: Initialise Parameters In the cell below you must define a function to initialise the weight matrices for each layer for a given list containing the size of each layer. We will use a straightforward method of initializing randomly from a Gaussian distribution with a variance of 1 and 0 mean. The bias vectors will be initialized with zeros. helpful functions: np.random.randn() np.zeros()

In [ ]: def init(sizes): Initialize parameters Arguments: sizes (list): shape [n_Layers, ], List of the sizes for the Layers. Returns: params (dict): dict containing the randomly initialized (use the default Gaussian distribution with variance o f 1 and a mean) weights and biases. 'wl' between input and hidden Layer 'b1' for the hidden Layer 'w2' between hidden Layer and output 'b2' for the output Layer params = { 'wi': None, 'b1': None, 'W2': None, 'b2': None, } # YOUR CODE HERE raise NotImplementedError() return params In [ ]: # free In [ ]: sizes_grade = [2, 3, 2] np.random. seed() params_grade = init(sizes_grade) params_test = { 'wi': np.array([[ 1.76405235, 0.40015721, 0.97873798], [ 2.2408932 1.86755799, -0.97727788]]), 'b1': np.array([0., 9., 0.]), 'W2': np.array([[ 0.95008842, -0.15135721], [-0.10321885, 0.4105985 ], [ 0.14404357, 1.45427351]]), 'b2': np.array([0., 0.]) } for param, value in params_test.items(): npt.assert_allclose(params_grade [param], value)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply