How to give target data in nntool or in nnstart?

2 次查看(过去 30 天)
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
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 中查找有关 Recognition, Object Detection, and Semantic Segmentation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by