-2

使用神经网络比训练它需要更长的时间。我做错了什么可怕的事情吗?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
4

1 回答 1

1

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

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

输出将是一个结果矩阵

于 2012-04-25T16:18:44.820 回答