无法使用MATLAB中的NEURAL NETWORKS来拟合数据

时间:2015-03-12 05:14:59

标签: matlab neural-network backpropagation

我一直在尝试使用matlab中的神经网络将数据拟合到非线性模型中。我有几组数据。我的代码适用于某些数据集但不适用于所有数据集。

对于某些数据集,我能够拟合良好的回归系数。对于某些数据集,它给出了一个恒定的输出值(即:几乎' 0'回归系数)。

这是我的神经网络的架构:前向神经网络与反向传播。没有隐藏层 - 隐藏层中没有神经元 - 我每次运行都会看到结果

任何人都可以指出我的代码中有什么错误请

  clear;
  %% to load data from excel file
  filename='dD.xlsx';
  x=xlsread(filename);
  p=x(:,2:12);
  t=x(:,1);
  inputs = p';
  targets = t';
  % rng(200,'v4');
  rng(0)
  %% Create a Fitting Network
  hiddenLayerSize = 5;
  net = fitnet(hiddenLayerSize);
  %% Set up Division of Data for Training, Validation, Testing
  % net.divideFcn = 'dividetrain';  % No validation or test data
  net.divideParam.trainRatio = 100/100;
  net.divideParam.valRatio = 0/100;
  net.divideParam.testRatio = 0/100;
  net.trainFcn = 'trainbr';
  % net = configure(net,ptrans,tn);
  net.layers{1}.transferFcn = 'logsig';
  net.layers{2}.transferFcn = 'purelin';
  %% Train the Network
  [net,tr] = train(net,inputs,targets);
  tr.best_epoch;
  effective_param = tr.gamk;
  effective_no_of_parameters = effective_param(length(effective_param));
  wt_IL=net.IW{1,1};
  wt_HL= net.LW{2,1};
  bias_IL=net.b{1};
  bias_HL=net.b{2};
  %% Test the Network
  outputs = net(inputs);
  errors = gsubtract(outputs,targets);
  performance = perform(net,targets,outputs)

0 个答案:

没有答案