필터 지우기
필터 지우기

How to give target data in nntool or in nnstart?

조회 수: 6 (최근 30일)
santhosh kumar buddepu
santhosh kumar buddepu 2021년 12월 7일
답변: Samay Sagar 2024년 4월 26일
I have created dataset of 94 B-scan images (76 training + 18 testing) consists of 3 classes (metal pipe, steel box, plastic box). I have extracted statistical features from images the size of training features is 76*6. and I have assigned labels using traindb.Labels, I can able to load input data as training features from work space but Iam unable to load target data.
My goal is to classify the three objects using NN classifier. I have classified these objects using ECOC-SVM but I'm unable to load target data using nntool. I'm attaching my code and database for your reference. please help me.
  댓글 수: 1
santhosh kumar buddepu
santhosh kumar buddepu 2021년 12월 8일
my labels are 76*1 categorical (metal pipe-19, plastic box-28, steel box-29). I need to classify into 3 classes and my target should be 76*3 which is in the form of
1 1 1....1(19) 0 0 0... (remaining)
0 0 0..0(19) 1 1 1...1(28) 0 0...0(remaining)
0 0 0......0(47) 1 1 1...1(29)
how to make target like this? please help me

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

답변 (1개)

Samay Sagar
Samay Sagar 2024년 4월 26일
To load target data for use with a Neural Network classifier, you need to convert your categorical labels into a format that the neural network can understand. This usually means transforming the labels into a one-hot encoded format if you are using a network that outputs class probabilities for each class.
Here is how you can modify your labels:
% Assuming traininglabels is a 76x1 categorical array with categories:
% 'metal pipe', 'plastic box', 'steel box'
% Initialize the target matrix with zeros
numImages = numel(traininglabels); % Number of training images
categoriesList = categories(traininglabels); % Get the list of categories
numClasses = numel(categoriesList); % Number of unique classes
targetMatrix = zeros(numImages, numClasses);
% For each class, set the appropriate entries in the target matrix to 1
for classIndex = 1:numClasses
className = categoriesList{classIndex}; % Access the category name correctly
% Find all rows in traininglabels that belong to the current class
rowsOfClass = traininglabels == className;
% Set the corresponding entries in the target matrix to 1
targetMatrix(rowsOfClass, classIndex) = 1;
end
% Now, targetMatrix is your desired 76x3 target matrix
You can follow a similar approach to prepare your testing target data.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by