MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / _maximize_phi

Method _maximize_phi

numpy_ml/lda/lda.py:36–58  ·  view source on GitHub ↗

Optimize variational parameter phi ϕ_{t, n} ∝ β_{t, w_n} e^( Ψ(γ_t) )

(self)

Source from the content-addressed store, hash-verified

34 self.T = T
35
36 def _maximize_phi(self):
37 """
38 Optimize variational parameter phi
39 ϕ_{t, n} ∝ β_{t, w_n} e^( Ψ(γ_t) )
40 """
41 D = self.D
42 N = self.N
43 T = self.T
44
45 phi = self.phi
46 beta = self.beta
47 gamma = self.gamma
48 corpus = self.corpus
49
50 for d in range(D):
51 for n in range(N[d]):
52 for t in range(T):
53 w_n = int(corpus[d][n])
54 phi[d][n, t] = beta[w_n, t] * np.exp(dg(gamma, d, t))
55
56 # Normalize over topics
57 phi[d][n, :] = phi[d][n, :] / np.sum(phi[d][n, :])
58 return phi
59
60 def _maximize_gamma(self):
61 """

Callers 1

_E_stepMethod · 0.95

Calls 1

dgFunction · 0.85

Tested by

no test coverage detected