使用神经网络比训练需要更长的时间。我做错了什么吗? 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
答案 0 :(得分:1)
您必须对输入进行矢量化。用以下代码替换for循环:
test_input = buildingInputs(:,:);
tic
test_output = net(test_input);
time = time + toc;
输出将是结果矩阵