Simulating neural network with code

2 次查看(过去 30 天)
pter
pter 2015-5-1
I trained multiple neural networks in Matlab for head pose estimation. To implement the neural networks in a real-time setting I want to simulate the networks in another language, so I start writing code for Matlab first.
When I tested this code on the training set, I found out that my outputs (yaw and pitch angle) are slightly different from the outputs the training gave me. The differences are on average only one degree, but it should exactly be the same.
I already did pre- and postprocessing with mapminmax. Can anyone please tell me what I am missing here!?
My code:
target_train = target_train';
[~,outMapP] = mapminmax(target_train(1,:), -1, 1);
[~,outMapY] = mapminmax(target_train(2,:), -1, 1);
pitch = [];
yaw = [];
for i = 1:1568;
image = input_train(i,:);
%Map image between -1 and +1
[~, inMap] = mapminmax(image, -1, 1);
image = mapminmax('apply', image, inMap);
adder1 = image*IW';
layer1 = tansig(adder1'+b1);
adder2 = LW*layer1;
layer2 = purelin(adder2+b2);
out_pitch = layer2(1,1);
out_yaw = layer2(2,1);
pitch = [pitch; out_pitch];
yaw = [yaw; out_yaw];
end
%Remap the output to the right range
pitch = mapminmax('reverse', pitch, outMapP);
yaw = mapminmax('reverse', yaw, outMapY);
  1 个评论
Greg Heath
Greg Heath 2015-5-6
MATLAB was invented to be a MATRIX based language to omit unnecessary loops.
Try using matrix equations instead of loops.
Greg

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by