Index exceeds matrix dimensions
2 次查看(过去 30 天)
显示 更早的评论
I run a program of Improved Dense Trajectory features Encoded by Fisher Vector, written by Bo Yang. Below shows a part of the coding.
for i=1:dtf_feat_num
feat=feats_train{i};
% L1 normalization & Square root
feat=sqrt(feat/norm(feat,1));
% Do PCA on train/test data to half-size original descriptors
fprintf('Doing PCA ...\n');
pca_coeff{i} = princomp(feat');
pca_coeff{i} = pca_coeff{i}(:, 1:floor(size(feat,1)/2))';
% dimensionality reduction
feat = pca_coeff{i} * feat;
fprintf('Training Guassian Mixture Model ...\n');
gmm{i}=gmm_gen_codebook(feat,gmm_params);
end
When i run the master.m , it shows the error below:
Index exceeds matrix dimensions.
Error in pretrain (line 57)
pca_coeff{i} = pca_coeff{i}(:, 1:floor(size(feat,1)/2))';
Can anyone help me to solve this problem? Thank you.
3 个评论
Geoff Hayes
2019-3-2
Mohamad's answer moved here
The dimension of pca_coeff is 4x1.
The code below are the looping part:
for i=1:dtf_feat_num
feat=feats_train{i};
% L1 normalization & Square root
feat=sqrt(feat/norm(feat,1));
% Do PCA on train/test data to half-size original descriptors
fprintf('Doing PCA ...\n');
pca_coeff{i} = pca(feat');
pca_coeff{i} = pca_coeff{i}(:, 1:floor(size(feat,1)/2))';
% dimensionality reduction
feat = pca_coeff{i} * feat;
fprintf('Training Guassian Mixture Model ...\n');
gmm{i}=gmm_gen_codebook(feat,gmm_params);
end
end
Below are value of the variables in the coding:
dtf_feat_num = 4
feat = 96x985 double
floor(size(feat,1)/2) = 48
Geoff Hayes
2019-3-2
And what are the dimensions of the elements in the pca_coeff array? You may need to put a breakpoint at this line, run your code and step through it with the debugger to see what is happening.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!