How to give target data in nntool or in nnstart?

3 ビュー (過去 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 Center および File ExchangeRecognition, 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