MATLAB: How tonitialize the weights randomly and train for 20 different sets of initial weights

Deep Learning Toolboxneural networkneural networks

Hii all
I have a problem in neural network and i am stuck with that. First of all this is my first experience in NN as well as in this blog. Let me thank everyone in advance.
I am using matlab 2012 for my problem. I have four set of gray scale images. I would like to make these image pixels (from each four Images) as my input. I have extracted the values of each pixel and maid it as 4*200000 matrix. For these corresponding inputs I have 1*200000 matrix as my target.
I have tried using hidden layer size as [10 10]. I could edit the mfile to give
hiddenLayerSize = [10 10];
net = fitnet(hiddenLayerSize);
% net = feedforwardnet;
% net = feedforwardnet([40 10]);
% net = configure(net,inputs,targets);
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'tansig';
% net.layers{3}.transferFcn = 'tansig';
net.layers{3}.transferFcn = 'purelin';
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 10/100;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
% View the Network
view(net)code
end
In this I have a confusion in selection of NN "net = feedforwardnet or net = feedforwardnet or net=fitnet??
I could get a solution for fitnet but How to understand it is trained well??
Its too slow in training ( May be due to large training set)Any suggestions?
I have converted every input in between -1 and 1 using mapminmax then shuffled accordingly for avoiding memorization of NN.
Every training for the same input and target resulted in different answers as expected. But how to initialize the weights randomly for 20 different sets and train them together and identify the best out of it?
Thanks For your valid time

Best Answer

1. I would first consider
a. Feature extraction to reduce the size of the matrices
b. Data division and an ensemble of smaller nets
2. One hidden layer is sufficient
3. A more equal trn/val/tst division
4. Use tr to separate the trn/val/tst responses.
Hope this helps.
Thank you for formally accepting my answer