我有一些使用神经网络的代码。
当我像这样使用非内存前馈网络时:
feedforwardnet(nHidden);
一切正常,我对我想要的函数有很好的近似。
但是,如果我像这样切换到 timedelaynet:
timedelaynet(1:1, nHidden);
神经网络的输出即:
a1 = mainNet(inputsD');
是多个常数;绿色为目标(近似的数据),红色为输出:
我究竟做错了什么?
以下是其他 NN 初始化代码行:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nHidden = 3;
if (TDN)
mainNet = timedelaynet(1:1, nHidden);
else
mainNet = feedforwardnet(nHidden);
end
% Choose data division type:
% 'dividerand' : Random division.
% 'divideblock' : Block division.
% 'divideint' : Interleaved division.
mainNet.divideFcn = 'dividerand';
% Setup division of data for training:
mainNet.divideParam.trainRatio = 70/100;
mainNet.divideParam.valRatio = 15/100;
mainNet.divideParam.testRatio = 15/100;
% Choose training algorithm:
% 'trainlm' : Levenberg-Marquardt.
% 'trainrp' : Good for pattern recognition, bad for regression.
% 'trainscg' : Conjugate Gradient, good for larger networks.
% 'traingdx' : Variable learning rate.
% 'trainbr' : Bayesian Regularization.
mainNet.trainFcn = 'trainlm';
mainNet.layers{1:1}.transferFcn = 'tansig';
mainNet.trainParam.min_grad = 1e-100;
mainNet.trainParam.goal = 1e-10;
mainNet.trainParam.epochs = 300000;
mainNet.trainParam.max_fail = 100000000;
mainNet.trainParam.mu_inc = 4;
mainNet.trainParam.mu_max = 1e200;
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%