1 % Sparse Feature Fidelity (SFF)
2 % Training on image samples by ICA
3 % FastICA (Aapo Hyvarinen)
5 % Z : whitened image patch data
6 % n : number of independent components to be estimated
9 %create random initial value of W, and orthogonalize it
10 W = orthogonalizerows(randn(n,size(Z,1)));
12 %read sample size from data matrix
18 while notconverged && (iter<2000) %maximum of 2000 iterations
24 % Compute estimates of independent components
27 % Use tanh non-linearity
30 % This is the fixed-point step.
31 % Note that 1-(tanh y)^2 is the derivative of the function tanh y
32 W = gY*Z'/N - (mean(1-gY'.^2)'*ones(1,size(W,2))).*W;
34 % Orthogonalize rows or decorrelate estimated components
35 W = orthogonalizerows(W);
37 % Check if converged by comparing change in matrix with small number
38 % which is scaled with the dimensions of the data
39 if norm(abs(W*Wold')-eye(n),'fro') < (1e-8) * n;