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/debugInitializeWeights.m
864 views
1
function W = debugInitializeWeights(fan_out, fan_in)
2
%DEBUGINITIALIZEWEIGHTS Initialize the weights of a layer with fan_in
3
%incoming connections and fan_out outgoing connections using a fixed
4
%strategy, this will help you later in debugging
5
% W = DEBUGINITIALIZEWEIGHTS(fan_in, fan_out) initializes the weights
6
% of a layer with fan_in incoming connections and fan_out outgoing
7
% connections using a fix set of values
8
%
9
% Note that W should be set to a matrix of size(1 + fan_in, fan_out) as
10
% the first row of W handles the "bias" terms
11
%
12
13
% Set W to zeros
14
W = zeros(fan_out, 1 + fan_in);
15
16
% Initialize W using "sin", this ensures that W is always of the same
17
% values and will be useful for debugging
18
W = reshape(sin(1:numel(W)), size(W)) / 10;
19
20
% =========================================================================
21
22
end
23
24