필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to adjust trainNetwork to meet the solution of train?

조회 수: 1 (최근 30일)
Michael
Michael 2018년 5월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
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