Random initialization
This commit is contained in:
parent
863f1d7157
commit
052f0625c3
1 changed files with 6 additions and 11 deletions
|
@ -1,15 +1,15 @@
|
||||||
function W = randInitializeWeights(L_in, L_out)
|
function W = randInitializeWeights(L_in, L_out)
|
||||||
%RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in
|
%RANDINITIALIZEWEIGHTS Randomly initialize the weights of a layer with L_in
|
||||||
%incoming connections and L_out outgoing connections
|
%incoming connections and L_out outgoing connections
|
||||||
% W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights
|
% W = RANDINITIALIZEWEIGHTS(L_in, L_out) randomly initializes the weights
|
||||||
% of a layer with L_in incoming connections and L_out outgoing
|
% of a layer with L_in incoming connections and L_out outgoing
|
||||||
% connections.
|
% connections.
|
||||||
%
|
%
|
||||||
% Note that W should be set to a matrix of size(L_out, 1 + L_in) as
|
% Note that W should be set to a matrix of size(L_out, 1 + L_in) as
|
||||||
% the column row of W handles the "bias" terms
|
% the column row of W handles the "bias" terms
|
||||||
%
|
%
|
||||||
|
|
||||||
% You need to return the following variables correctly
|
% You need to return the following variables correctly
|
||||||
W = zeros(L_out, 1 + L_in);
|
W = zeros(L_out, 1 + L_in);
|
||||||
|
|
||||||
% ====================== YOUR CODE HERE ======================
|
% ====================== YOUR CODE HERE ======================
|
||||||
|
@ -19,13 +19,8 @@ W = zeros(L_out, 1 + L_in);
|
||||||
% Note: The first row of W corresponds to the parameters for the bias units
|
% Note: The first row of W corresponds to the parameters for the bias units
|
||||||
%
|
%
|
||||||
|
|
||||||
|
epsilon_init = 0.12;
|
||||||
|
W = rand(L_out, 1 + L_in) * 2 * epsilon_init - epsilon_init;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
% =========================================================================
|
% =========================================================================
|
||||||
|
|
||||||
|
|
Reference in a new issue