function net=initnet(net, weight_range)
%INITNET	Initialize the weights of a feed-forward neural network.
%
%	net = INITNET (net, weight_range);
%
%	Example: net = INITNET (net, [-0.2, 0.2]);
%	Initialize weights to range [-0.2, 0.2].
%
%	See also: NEWNET.

%	Ling Li, Caltech
%	10/21/96, 10/08/00

% Check inputs
if nargin < 2 | length(weight_range) < 2
	error('Input error. Type ''help initnet'' to get more info.');
end

for l = 1:net.layers-1
	net.weight{l} = rand(net.neurons(l)+1, net.neurons(l+1)) ...
		* (weight_range(2) - weight_range(1)) + weight_range(1);
end