I got very different training efficiency with the following network
net = patternnet(hiddenLayerSize);
and the following one
net = feedforwardnet(hiddenLayerSize, 'trainscg'); net.layers{1}.transferFcn = 'tansig'; net.layers{2}.transferFcn = 'softmax'; net.performFcn = 'crossentropy';
on the same data.
I was thinking networks should be the same.
What thing I forgot?
UPDATE
The code below shows, that patternnet is systemtically outperforms feedforwardnet. This proves that feedforwardnet is initilized differently somehow. The question is what is the difference?
hiddenLayerSize = 10; % pass 1, with patternnet
net = patternnet(hiddenLayerSize); net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100; [net,tr] = train(net,x,t); y = net(x); performance = perform(net,t,y); fprintf('pass 1, patternnet, performance: %f\n', performance); fprintf('num_epochs: %d, stop: %s\n', tr.num_epochs, tr.stop); % pass 2, with feedforwardnet
net = feedforwardnet(hiddenLayerSize, 'trainscg'); net.layers{1}.transferFcn = 'tansig'; net.layers{2}.transferFcn = 'softmax'; net.performFcn = 'crossentropy'; net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100; [net,tr] = train(net,x,t); y = net(x); performance = perform(net,t,y); fprintf('pass 2, feedforwardnet, performance: %f\n', performance); fprintf('num_epochs: %d, stop: %s\n', tr.num_epochs, tr.stop); % pass 1, with patternnet net = patternnet(hiddenLayerSize); net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100; [net,tr] = train(net,x,t); y = net(x); performance = perform(net,t,y); fprintf('pass 3, patternnet, performance: %f\n', performance); fprintf('num_epochs: %d, stop: %s\n', tr.num_epochs, tr.stop); % pass 2, with feedforwardnet net = feedforwardnet(hiddenLayerSize, 'trainscg'); net.layers{1}.transferFcn = 'tansig'; net.layers{2}.transferFcn = 'softmax'; net.performFcn = 'crossentropy'; net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100; [net,tr] = train(net,x,t); y = net(x); performance = perform(net,t,y); fprintf('pass 4, feedforwardnet, performance: %f\n', performance); fprintf('num_epochs: %d, stop: %s\n', tr.num_epochs, tr.stop);
Output follows:
pass 1, patternnet, performance: 0.116445 num_epochs: 353, stop: Validation stop. pass 2, feedforwardnet, performance: 0.693561 num_epochs: 260, stop: Validation stop. pass 3, patternnet, performance: 0.116445 num_epochs: 353, stop: Validation stop. pass 4, feedforwardnet, performance: 0.693561 num_epochs: 260, stop: Validation stop.
Best Answer