Return first unique index of values
Show older comments
%function [mu,sig,p] = cifar_10_bayes_learn1(f, trlabel,N)
%trlabel=tr_labels(1:100)';
label=[1:10,2:11,3:12];
%N=16;
mu = zeros(10,(N*3));
%sig = zeros(10,3) %task1
sig = zeros((N*3),(N*3),10); %task2
p = zeros(10,1);
for i = 1:10
[row] = (find(label==i));
%[row] = find(trlabel==i-1)
for j=1:N
mu(i,j) = mean(f((row(i,j))));
mu(i,j+N) = mean(f((row(i,j+N))));
mu(i,(j+(2*N))) = mean(f((row(i,(j+(2*N))))));
end
mu(i,:)=[mu(i,j),mu(i,j+N),mu(i,(j+(2*N)))] %error in this, suscripted assignment dimension mismatch
% sig(:,:,i) = cov(f((row),:))
% %Sig(:,:,i)=(cov(f(row))+cov(f(row),:).')/2;
% p(i) = (length(row) / length(f))
end
end
The above code has to return 10 values in row vector,ie, the first index of unique values.The row values should be displayed as 1,2,3,...,10. I wanted to calculate mean,sigma for that particular indexed rows in training data.
2 Comments
madhan ravi
on 18 Oct 2018
Edited: madhan ravi
on 18 Oct 2018
Provide the input datas to test
Guillaume
on 18 Oct 2018
We have no idea what the above code is supposed to do since it's not commented. In addition, it's littered with unnecessary brackets making it harder to read (in my opinion), e.g. the line
mu(i,(j+(2*N))) = mean(f((row(i,(j+(2*N))))));
is simply
mu(i, j+2*N) = mean(f(row(i, j+2*N)));
You should explain the problem you're trying to solve in details, rather than giving us uncommented code that may or may not work.
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!