Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to adjust trainNetwork to meet the solution of train?

1 次查看(过去 30 天)
I tested train and trainNetwork on a test bench problem to investigate the difference.
%%generate data
N = 1e3;
x = linspace(0,4*pi,N);
y = sin(x)+0.5*sin(3*x)+0.25*sin(7*x);
figure(1);
plot(x,y); hold on;
%%train network
net = feedforwardnet([10 10]);
net.layers{1}.transferFcn = 'logsig'; % or 'tansig'
net.layers{2}.transferFcn = 'logsig';
net.trainFcn = 'trainbr'; % or 'trainlm'
net = train(net,x,y);
%%predict
ypred = net(x);
plot(x,ypred,'.');
%%train network
inputSize = 1;
numResponses = 1;
numHiddenUnits = 10;
layers = [sequenceInputLayer(inputSize);
fullyConnectedLayer(numHiddenUnits);
fullyConnectedLayer(numHiddenUnits);
fullyConnectedLayer(numResponses);
regressionLayer];
opts = trainingOptions('adam','MaxEpochs',250,'Plots','training-progress','InitialLearnRate',0.01, ...
'LearnRateSchedule','piecewise','LearnRateDropFactor',0.75,'LearnRateDropPeriod',100, ...
'MiniBatchSize',9e9,'L2Regularization',0.0001);
%%train the network
net = trainNetwork(x,y,layers,opts);
%%predict
ypred = predict(net,x);
plot(x,ypred,'.');
I tried different options for trainNetwork but the solution (straight line) stays the same. How do I have to adjust the options in order to achive the same performance as train?

回答(0 个)

此问题已关闭。

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by