How to Initialize the weights randomly and train for 20 different sets of initial weights?

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

2 Comments

I do not understand what you are trying to do AND why you think a neural network should be used to obtain a solution?
Please explain what you are trying to do without mentioning neural networks.
There are several problems with your code.
However, let's first get it straight as to
1. What are you trying to do?
2. Why?
Greg
Yes Sir
The situation is, I have 4 set of images having same dimension with different attributes. These four images are processed to give me another resultant image with same dimension.
The gray scale value of each pixel in my resultant image can be used as a measure of some property(Infection level,curing state,stress etc)at that pixel location.
I can take 4 images with different conditions and process those 4 images to obtain the resultant Image. I have a known situation, where I know the pixel gray scale value of these 4 images and my resultant Image. I want to train the network using this known situation ( 4 images as input, and Resultant image as target).
Once it is ready I can use this network and input another set of 4 images and get the predicted resultant Image. The gray scale value of the resultant will help me in quantifying the unknown data.
Thanks and regards
Hari

Sign in to comment.

 Accepted 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

More Answers (1)

As far as answering the questions in the title:
1. Random weight initialization is a default
2. Search using
greg Ntrials
Thank you for formally accepting my answer
Greg

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!