File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 1- function [model , energy ] = ppcaVb(X , q , prior )
1+ function [model , L ] = ppcaVb(X , q , prior )
22% Perform variatioanl Bayeisan inference for probabilistic PCA model.
33% Input:
44% X: d x n data matrix
2727end
2828tol = 1e-6 ;
2929maxIter = 500 ;
30- energy = - inf(1 ,maxIter );
30+ L = - inf(1 ,maxIter );
3131
3232mu = mean(X ,2 );
3333Xo = bsxfun(@minus , X , mu );
6767% Emu = Ebeta/(lambda+n*Ebeta)*sum(X-WZ,2);
6868
6969% lower bound
70- energy (iter ) = KLalpha + KLbeta + KLW + KLZ ;
71- if energy (iter )-energy (iter - 1 ) < tol * abs(energy (iter - 1 )); break ; end
70+ L (iter ) = KLalpha + KLbeta + KLW + KLZ ;
71+ if L (iter )-L (iter - 1 ) < tol * abs(L (iter - 1 )); break ; end
7272end
73- energy = energy (2 : iter );
73+ L = L (2 : iter );
7474
7575model.Z = EZ ;
7676model.W = EW ;
Original file line number Diff line number Diff line change 11% demos for ch12
2-
32clear ; close all ;
43d = 3 ;
54m = 2 ;
65n = 1000 ;
76
87X = ppcaRnd(m ,d ,n );
98plotClass(X );
10-
119%% Variational Bayesian probabilistic PCA
12- [model , energy ] = ppcaVb(X );
13- plot(energy );
10+ [model , L ] = ppcaVb(X );
11+ plot(L );
You can’t perform that action at this time.
0 commit comments