I was trying to simulate MATLAB’s NN functions before testing my own coded network. I was training y = x1+x2.
But see how it performed,
>> net = newfit([1 2 3 4 5 0 1 2 5;1 2 3 4 5 1 1 1 1],[2 4 6 8 10 0 2 3 6],15);
>> net = train(net,[1 2 3 4 5 0 1 2 5;1 2 3 4 5 1 1 1 1],[2 4 6 8 10 0 2 3 6]);
>> sim(net,[1;4])
ans =
12.1028
>> sim(net,[4;4])
ans =
8.0000
>> sim(net,[4;1])
ans =
3.0397
>> sim(net,[2;2])
ans =
5.1659
>> sim(net,[3;3])
ans =
10.3024
Can anyone explain what is wrong with these training data? Is it not enough to estimate y = x1+x2 ? Or it just over-specialized? I believe it is a regression problem. Now, I do not know what should I expect from my own coded network. I was wondering on basis of what criteria this NN converges where it is producing such stupid result? is there any way to know what function it maps to (I know no way !)? My own network would not even converge , because it checks sum squared error as loop break condition. So how to deal with such training pattern?
However, I have another awesome training pattern which I am unable to train.
Can anyone train the following data set? Will it work/converge?
0 0 ——-> 0
0 1 ——-> 1000
1000 0 —-> 1
1 1 ——-> 0
I have been using f(x)=x in output layer and used back propagation algorithm , but for this pattern the code never seems converge.
By calling
you create an ANN with hidden layers of size 15, which is probably too much for your problem. Besides, your training set is too small.
Here is a working code (it will take a while on old computers), I let you analyze it and diff with yours, please ask should you need further explanations:
Results are virtually perfect:
PS: NEWFIT is obsoleted in R2010b NNET 7.0. Last used in R2010a NNET 6.0.4.