Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 5/Programming Assignment - 4/machine-learning-ex4/ex4/randInitializeWeights.m
864 views
1
function W = randInitializeWeights(L_in, L_out)
2
%RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in
3
%incoming connections and L_out outgoing connections
4
% W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights
5
% of a layer with L_in incoming connections and L_out outgoing
6
% connections.
7
%
8
% Note that W should be set to a matrix of size(L_out, 1 + L_in) as
9
% the first column of W handles the "bias" terms
10
%
11
12
% You need to return the following variables correctly
13
W = zeros(L_out, 1 + L_in);
14
15
% ====================== YOUR CODE HERE ======================
16
% Instructions: Initialize W randomly so that we break the symmetry while
17
% training the neural network.
18
%
19
% Note: The first column of W corresponds to the parameters for the bias unit
20
%
21
epsilon_init = 0.12;
22
W = rand(L_out, 1 + L_in) * 2 * epsilon_init - epsilon_init;
23
% =========================================================================
24
25
end
26
27