how to store target into array bpnn?
1 次查看(过去 30 天)
显示 更早的评论
if true
% code
endhi, i'm working on project of classification images. i have 4 classes. the dataset of the training in the last column is the class label where 4 class. 1-4.
how to write a code to store the target into array. i want to make if the target is 4, it will store 1000. my code below did not work.
loadinput = dlmread('Train.csv');<
x = loadinput;
tempt = loadinput;
x(:,2501)=[];
noofInputSet = length(x(:,1));
disp(noofInputSet);
noofInputNode = length(x(1,:));
noofHiddenNode = noofInputNode / 2;
noofInputBiasNode = 1;
noofHiddenBiasNode = 1;
noofOutputNode = 4;
for r=1:noofInputNode
tempt(:,1)=[];
%store target into array t
for sT=1:noofInputSet
if tempt(sT)==1,
t(sT) =1000;
elseif tempt(sT)==2,
t(sT) = 0100;
elseif tempt(sT)==3,
t(sT)=0010;
elseif tempt (sT)==4,
t(sT)=0001;
end
-can somebody help me fix this
0 个评论
回答(1 个)
Greg Heath
2016-6-15
TARGET VECTORS SHOULD BE COLUMNS OF THE UNIT MATRIX eye(4)
classindices = [ 1 2 3 4 3 2 1]
target = full(ind2vec(classindices))
classindices = vec2ind(target)
Hope this helps.
Thank you for formally accepting my answer
Greg
2 个评论
另请参阅
类别
在 Help Center 和 File 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!