通过以下网络,我得到了非常不同的培训效率
net = patternnet(hiddenLayerSize);和下一个
net = feedforwardnet(hiddenLayerSize, 'trainscg');
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'softmax';
net.performFcn = 'crossentropy';同样的数据。
我在想网络应该是一样的。
我忘了什么东西?
更新
下面的代码演示了,网络行为是唯一依赖于网络创建功能的。
每种类型的网络运行两次。这不包括随机的生成器问题什么的。数据是一样的。
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);产出如下:
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.发布于 2015-04-21 02:44:11
看起来这两个不太一样:
>> net = patternnet(hiddenLayerSize);
>> net2 = feedforwardnet(hiddenLayerSize,'trainscg');
>> net.outputs{2}.processParams{2}
ans =
ymin: 0
ymax: 1
>> net2.outputs{2}.processParams{2}
ans =
ymin: -1
ymax: 1net.outputs{2}.processFcns{2}是mapminmax,所以我认为其中之一是调整它的输出以更好地匹配实际数据的输出范围。
为了将来的参考,您可以通过转换到struct来做一些肮脏的事情,比如比较内部的数据结构。所以我做了一些事情
n = struct(net); n2 = struct(net2);
for fn=fieldnames(n)';
if(~isequaln(n.(fn{1}),n2.(fn{1})))
fprintf('fields %s differ\n', fn{1});
end
end帮助找出不同之处。
发布于 2015-04-09 09:10:46
通常情况下,网络并不是每次训练都表现出完全相同的方式。这取决于三个(我的意思是我知道三个)的原因:
https://stackoverflow.com/questions/29523137
复制相似问题