【问题标题】:how to speed up neural network performance in matlab?如何在matlab中加快神经网络的性能?
【发布时间】:2012-05-05 17:33:26
【问题描述】:

使用神经网络比训练它需要更长的时间。我做错了什么可怕的事情吗? 2 分钟使用 vs 14 秒训练。

load building_dataset % 4208 examples

inputs = buildingInputs; 
targets = buildingTargets;

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

% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;

% Train the Network
tic
[net,tr] = train(net,inputs,targets);
training_time = toc % ~= 14 seconds

% use the neural network
time = 0;
for i = 1:4208
  test_input = buildingInputs(:,i);
  tic
  test_output = net(test_input);
  time = time + toc;
end

time % ~= 117 seconds
average_time = time / 4208 % ~= 0.028 seconds

【问题讨论】:

    标签: matlab neural-network


    【解决方案1】:

    您必须对输入进行矢量化处理。用这个替换 for 循环:

      test_input = buildingInputs(:,:);
      tic
      test_output = net(test_input);
      time = time + toc;
    

    输出将是一个结果矩阵

    【讨论】:

      猜你喜欢
      • 2015-03-13
      • 2015-12-03
      • 2011-08-23
      • 2021-06-18
      • 2014-01-15
      • 1970-01-01
      • 2015-08-13
      • 2013-12-10
      相关资源
      最近更新 更多