how to create a target set for ANN classification???
3 次查看(过去 30 天)
显示 更早的评论
i am trying to create a target set for my inputs to be used in classification with ANN but i have some challenges . i have 23 classes of images of which each class contains 100 images. feature extraction was done and i got a matrix of 2300*20736. how can i create a target set for my inputs.
0 个评论
采纳的回答
Baptiste Ottino
2017-8-14
Your target set must have one label for each sample, so it must contains 2300 elements. Here is an easy way to build one. Start by numbering your classes from 1 to 23. Make sure that your X Array is sorted by class, meaning all the samples from the first class, then all the samples from the second class, and so on. Then:
% Classes from 1 to 23
y = 1:23;
% 100 samples per class
y = repmat(y, 100, 1);
% Reshape to obtain a vector
y = reshape(y, 1, numel(y));
At this stage, you should have a 1-by-2300 vector with numeric class labels from 1 to 23. This is what you want if you use the Statistics and Machine Learning tToolbox.
Now, I suppose you intend to use the Neural Network Toolbox. In that case the syntax is a bit different: the class labels are in a 23-by-2300 matrix, each column being a sample, with the row corresponding to the class getting value '1' and the rest '0'. To build it from the previous syntax, type:
y = full(ind2vec(y));
Good luck!
3 个评论
shivasmic
2019-6-24
Baptiste ottino, thanx for the method, the method that you suggest for the comnstruction of target vector leads to the creation of matrix which has dimensions of 23 x 2300 but the input vector has dimension of 2300 x 20736.
Dont you think that the dimension of target vector should also be 2300 x 23.
I am asking this as I am also facing the same problem. Kindly clarify this as soon as possible!
更多回答(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!