Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to adjust trainNetwork to meet the solution of train?

1 vue (au cours des 30 derniers jours)
Michael
Michael le 9 Mai 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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?

Réponses (0)

Cette question est clôturée.

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by