How to create inputs and targets for Neural Network?

조회 수: 6 (최근 30일)
Lauren Pitts
Lauren Pitts 2019년 8월 2일
댓글: Lauren Pitts 2019년 8월 7일
I need to know how to set my SURF code as my input (x) and ind out what my target (t) needs to be.
This is my neural network code:
close all;
clear;
%%GOAL%%
% get 300 images
% x = 640 x 300
% t = 3 x 300
[x,t] = ?????
net = patternnet(10);
view(net);
[net,tr] = train(net,x,t);
nntraintool;
plotperform(tr)
testX = x(:,tr.testInd);
testT = t(:,tr.testInd);
testY = net(testX);
testIndices = vec2ind(testY);
plotconfusion(testT,testY)
I need to add my SURF extraction code as my input (I think) but I have no idea what the t-target is.
SURF extraction code:
images_dir ='C:\Users\pittsl\Desktop\Matlab\train\cup';
pngfiles=dir(fullfile(images_dir,'\*.png*'));
n=numel(pngfiles);
for i=1:n
figure;
image = pngfiles(i).name;
im1 = imread(fullfile(images_dir,image));
I = rgb2gray(im1);
imshow(I);
points = detectSURFFeatures(I);
imshow(I);
hold on;
plot(points.selectStrongest(10));
[features, valid_points] = extractFeatures(I, points);
plot(valid_points.selectStrongest(5),'showOrientation',true);
end

채택된 답변

Shashank Gupta
Shashank Gupta 2019년 8월 5일
Hi,Lauren
detectSURFFeatures” function is just a feature extraction tool, it will help you to extract important information about the image in a robust way. I am assuming you want your input not to be multidimensional data whereas descriptor gives multidimensional data. One way to tackle this is to use “bag of features”. It discretizes the space of descriptor and gives you a single vector.
You can check out furthermore on “bag of features” in
On the other hand, Target (t) vector you can construct it depending on whether you want to classify or detect something in Image.
For example, “an Iris dataset” has 3 classes and you want to classify the image in one of the three class, so target vector should look something like [0,0,1] (a categorical data) where “1” represent the image belong to that class.
Hope it helps!
  댓글 수: 1
Lauren Pitts
Lauren Pitts 2019년 8월 7일
@Shashank Gupta I'd never heard of bag of features but it worked perfectly! Thank you so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by