如何培训网络以获得更好的性能?

时间:2014-10-11 21:56:31

标签: neural-network

我有一个10乘57300矩阵作为输入,1乘57300矩阵作为输出,只包括0和1.I试图训练具有前馈反向传播和层重复反向传播结构的神经网络。我尝试了隐藏层中有一个隐藏层和40个神经元的结构。在最好的情况下,性能在0.133点停止。我用新输入模拟了网络,但它没有给我我想要的结果。结果与我训练网络的结果差不多。您有什么建议可以改善网络的性能吗?

inputs = input;
targets = output;

% Create a Fitting Network
hiddenLayerSize = 50;
net = fitnet(hiddenLayerSize);

% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};


% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'divideind';

net.divideParam.trainInd=1:28650;  % The first 94 inputs are for training.
net.divideParam.valInd=28651:42977;    % The first 94 inputs are for validation.
net.divideParam.testInd=42978:57300; % The last 5 inputs are for testing the network.

% For help on training function 'trainlm' type: help trainlm
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm';  % Levenberg-Marquardt

% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse';  % Mean squared error

% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
  'plotregression', 'plotfit'};


% Train the Network
[net,tr] = train(net,inputs,targets);

% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)

% Recalculate Training, Validation and Test Performance
trainTargets = targets .* tr.trainMask{1};
valTargets = targets  .* tr.valMask{1};
testTargets = targets  .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)

% View the Network
view(net)

% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, plotfit(net,inputs,targets)
%figure, plotregression(targets,outputs)
%figure, ploterrhist(errors)

这是我用于训练神经网络的代码。我的57300输入分为300X191组数据。我的意思是每组输入都是10乘191组。所以这就是我使用“divideind”的原因。我已将[-1 1]范围内的输入和输出矩阵归一化,因为我使用了tansig传递函数。但我仍然没有从网络中得到我想要的结果。

3 个答案:

答案 0 :(得分:1)

告诉如何用这么少的信息改进网络通常很复杂。在某些情况下,0.133的性能可能是一个好结果,而在其他情况下则不是那么好。尽管如此,改进网络的一般想法可以将输入归一化到[0,1]范围,执行特征选择,可能在监督反向传播学习方案之前添加rbm层并执行非监督训练(参见深度置信网络),增加用于学习的数据,或使用交叉验证来选择自由参数和提前停止。

答案 1 :(得分:1)

编辑v1:

我看到你有94个输入用于测试,94个用于验证,5个用于测试。这个比例似乎有点容易出错。

首先,特征向量为10的94个输入集非常少。对于100的特征向量是徒劳的:)。所以基本上问题是你没有足够的数据训练40个神经元。如果您无法生成更多数据,我建议您进行新的拆分:

150训练 10验证 30测试


此信息是提高NN性能的更通用的方法:

培训方法

多少纪元?网络可能过度训练您的输入集。 BP算法的参数(动量,适应因子等)

特征提取算法

通常,这是主要问题。该算法无法真正提取输入的特定功能

我建议直观地绘制所有输入,看看你是否看到任何图案,并能够直观地确定分离。毕竟,神经网络是一个更复杂的统计系统。

祝你好运!

答案 2 :(得分:0)

我不确定您是否正在训练您的网络以进行分类或回归。但如果您想直接提高性能,我建议您做以下事情:

1-进一步增加隐藏层中的节点数。尝试更大的东西,看看神经网络是否做得更好(可能是因为过度训练,但暂时忽略它)。

2-如果它们在数据空间中具有非常高的非线性,则再添加一个隐藏层。但是,在简单的神经网络的情况下,添加其中许多将不起作用。