How to get coordinate from Neural Network training image?
3 次查看(过去 30 天)
显示 更早的评论
I tried to study Neural Network tracking object from this thesis http://www.waset.org/journals/waset/v6/v6-50.pdf . I train image with newff. I define 2 node for output but it show double value not show coordinate. I don't know how to get coordinate from neural network. After I use function train and sim the result of variable A2 are [0.0658;0.0989]. please help me, how to get coordinate from Neural Network training image like the thesis? this is my code.
%Read image for train
I1 = imread('1.jpg');
I2 = imread('2.jpg');
I3 = imread('3.jpg');
G1 = rgb2gray(I1);
G2 = rgb2gray(I2);
G3 = rgb2gray(I3);
I1 = downsample(G1,9);
I2 = downsample(G2,9);
I3 = downsample(G3,9);
D1 = im2double(I1);
D2 = im2double(I2);
D3 = im2double(I3);
%Read image for test
I_test = imread('test_img.jpg');
G_test = rgb2gray(I_test);
I_test = downsample(G_test,9);
D_test = im2double(I_test);
M_test = D_test(:);
S1=10;
target = eye(2,3); %create target matrix.
M1 = D1(:);
M2 = D2(:);
M3 = D3(:);
M = M1; %reshape pattern for train
M(:,2) = M2;
M(:,3) = M3;
[R,Q]=size(M);
S2 = 2; % set output to 2 node
P = M;
net = newff(minmax(P),[S1 S2],{'logsig' 'logsig'});
P = M;
T= target;
net.performFcn = 'sse';
net.trainParam.goal = 0.1;
net.trainParam.show = 20;
net.trainParam.epochs = 5000;
net.trainParam.mc = 0.95;
[net,tr] = train(net,P,T);
netn = net;
netn.trainParam.goal = 0.6;
netn.trainParam.epochs = 300;
[netn,tr] = train(netn,P,T);
A2 = sim(netn,M(:,3));
%the result of variable A2 are [0.0658;0.0989]
0 个评论
回答(3 个)
Greg Heath
2012-3-31
>[net,tr] = train(net,P,T);
OK to here. The net is a classifier to recognize 3 types of images.
>netn = net;
>netn.trainParam.goal = 0.6;
>netn.trainParam.epochs = 300;
>[netn,tr] = train(netn,P,T);
WHY in the world was netn created??
>A2 = sim(netn,M(:,3));
Why not named A3?
%the result of variable A2 are [0.0658;0.0989]
Which looks OK because the target is [0.0 ; 0.0]
Delete every thing below the line "OK to here". Then add
A = sim(net,M)
ERROR = T - A
MSE = mse(ERROR)
MSE00 = mse(T-repmat(mean(T,2),1,3))
NMSE = MSE/MSE00 % Normalized Mean-Square-Error
R2 = 1- NMSE % Coefficient of Variation (See Wikipedia)
Please paste the results of these 6 added lines (Note: no semicolon)
Hope this helps.
Greg
0 个评论
Greg Heath
2012-4-3
As I stated above, the network is a classifier which will assign an input to one of three classes. You have to assign the coordinates that are associated with that class.
To make it easier to understand, make these changes
%target = eye(2,3)
target = eye(3)
class = vec2ind(target)
.
.
.
A = sim(net,M)
classA = vec2ind(A)
Hope this helps.
Greg
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!