📄 arch1.m
字号:
% Finds ICA representation of train and test images under Architecture I,
% described in Bartlett & Sejnowski (1997, 1998), and Bartlett, Movellan &
% Sejnowski (2002): In Architecture I, we load N principal component eigenvectors
% into rows of x, and then run ICA on x.
%
% Original aligned training images are in the rows of C, one image per row.
% In the following examples, there are 500 images of aligned faces of size
% 60x60 pixels, so C is 500x3600. This script also calls the matrix of PCA
% eigenvectors organized in the columns of V (3600x499). If you use the pca
% function in my companion code, then [V,R,E] = pcabigFn(C');
%
% The ICA representation will be in the rows of F (called B in Bartlett, Movellan &
% Sejnowski, 2002):
D = zeroMn(C')'; % D is 500x3600 and D = C-ones(500,1)*mean(C);
R = D*V; % R is 500x499 and contains the PCA coefficients;
% We choose to use the first 200 eigenvectors.
% (If PCA generalizes better by dropping first few eigenvectors, ICA will too).
x = V(:,1:200)'; % x is 200x3600
runica % calculates wz, w and uu. The matrix x gets
% overwritten by a sphered version of x.
F = R(:,1:200) * inv(w*wz); % F is 500x200 and each row contains the
% ICA1 rep of an image
% Representations of test images under architecture I:
% Put original aligned test images in rows of Ctest.
Dtest = zeroMn(Ctest')'; % For proper testing, subtract the mean of the
% training images not the test images:
% Dtest = Ctest-ones(500,1)*mean(C);
Rtest = Dtest*V;
Ftest = Rtest(:,1:200) * inv(w*wz);
% Test nearest neighbor using cosine, not euclidean distance, as similarity measure.
% See my companion code for functions that calculate nearest neighbor using cosines.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -