Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to adjust trainNetwork to meet the solution of train?

1 visualizzazione (ultimi 30 giorni)
Michael
Michael il 9 Mag 2018
Chiuso: MATLAB Answer Bot il 20 Ago 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?

Risposte (0)

Questa domanda è chiusa.

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by