📄 arch2.m
字号:
% Finds ICA representation of train and test images under Architecture II,
% described in Bartlett & Sejnowski (1997, 1998), and Bartlett, Movellan &
% Sejnowski (2002): In Architecture II, we load N principal component coefficients
% 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 F (called U 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;
x = R(:,1:200)'; % x is 200x500;
runica % calculates w, wz, and uu. The matrix x gets overwritten
% by a sphered version of x.
F = uu'; % F is 500x200 and each row contains the ICA2 rep of 1 image.
% F = w * wz * zeroMn(R(:,1:200)'); is the same thing.
% Watch out: x got overwritten by a sphered version of x by runica.
% Representations of test images under architecture II
% 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 = w * wz * zeroMn(Rtest(:,1:200)');
% 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 + -