How to implement nguyen widrow weight initialization ?
3 views (last 30 days)
Show older comments
Hi, I'm interested to use nguyen widrow weight initialization but i do not want to use the existing matlab function. I have the pseudo code and I want to try coding it myself. One thing I'm not sure on is how the technique calculate the norm of weights ? suppose I have input weights of [5x3] do i calculate the norm of entire matrix or column ? Thanks in advance
0 Comments
Answers (2)
Ênio Viana
on 18 May 2018
In this link you can see a Matlab code implementation Stack Overflow but I didn't test this. See that code...
a = -1;
b = 1;
% WIDROW weights for Layer Input to Hidden Layer 1
sum_sq_wts = 0;
for k=1:30
iw(:,:) = zeros(num_input, nodes_hidden_layer);
for i=1:num_input
for j=1:nodes_hidden_layer
iw(i,j)=(b-a)*rand(1,1) + a;
sum_sq_wts = sum_sq_wts + (iw(i,j)*iw(i,j));
end
end
norm = sqrt(sum_sq_wts);
beta = 0.7*nodes_hidden_layer.^(1/num_input);
for i=1:num_input
for j=1:nodes_hidden_layer
iw(i,j) = beta*iw(i,j)/norm;
end
end
IW{k}=iw';
end
% WIDROW weights for Hidden Layer 1 to output Layer
sum_sq_wts = 0;
for k=1:30
lw(:,:) = zeros(nodes_hidden_layer,1);
for i=1:nodes_hidden_layer
for j=1:1
iw(i,j)=(b-a)*rand(1,1) + a;
sum_sq_wts = sum_sq_wts + iw(i,j)*iw(i,j);
end
end
norm = sqrt(sum_sq_wts);
beta = 0.7*nodes_hidden_layer.^(1/num_input);
for i=1:nodes_hidden_layer
for j=1:1
lw(i,j) = beta*lw(i,j)/norm;
end
end
LW{k}=lw';
end
WidNgu{1,1} = IW;
WidNgu{1,2} = LW;
See Also
Categories
Find more on Quantum Mechanics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!