Task 1: Initialise Parameters In the cell below you must define a function to initialise the weight matrices for each la
-
- 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
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)