|
a |
|
b/combinedDeepLearningActiveContour/functions/initializeParameters.m |
|
|
1 |
function theta = initializeParameters(hiddenSize, visibleSize) |
|
|
2 |
|
|
|
3 |
%% Initialize parameters randomly based on layer sizes. |
|
|
4 |
r = sqrt(6) / sqrt(hiddenSize+visibleSize+1); % we'll choose weights uniformly from the interval [-r, r] |
|
|
5 |
W1 = rand(hiddenSize, visibleSize) * 2 * r - r; |
|
|
6 |
W2 = rand(visibleSize, hiddenSize) * 2 * r - r; |
|
|
7 |
|
|
|
8 |
b1 = zeros(hiddenSize, 1); |
|
|
9 |
b2 = zeros(visibleSize, 1); |
|
|
10 |
|
|
|
11 |
% Convert weights and bias gradients to the vector form. |
|
|
12 |
% This step will "unroll" (flatten and concatenate together) all |
|
|
13 |
% your parameters into a vector, which can then be used with minFunc. |
|
|
14 |
theta = [W1(:) ; W2(:) ; b1(:) ; b2(:)]; |
|
|
15 |
|
|
|
16 |
end |
|
|
17 |
|