Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to adjust trainNetwork to meet the solution of train?

1 visualización (últimos 30 días)
Michael
Michael el 9 de Mayo de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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?

Respuestas (0)

La pregunta está cerrada.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by