Index exceeds matrix dimensions

2 visualizzazioni (ultimi 30 giorni)
Mohamad Afiq
Mohamad Afiq il 1 Mar 2019
Commentato: Geoff Hayes il 2 Mar 2019
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 Commenti
Geoff Hayes
Geoff Hayes il 2 Mar 2019
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 il 2 Mar 2019
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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Dimensionality Reduction and Feature Extraction in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by