Index exceeds matrix dimensions

조회 수: 2 (최근 30일)
Mohamad Afiq
Mohamad Afiq 2019년 3월 1일
댓글: Geoff Hayes 2019년 3월 2일
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
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
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개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by