MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / init_random

Method init_random

hmm_class/hmmc_tf.py:29–44  ·  view source on GitHub ↗
(self, X)

Source from the content-addressed store, hash-verified

27 self.session = session
28
29 def init_random(self, X):
30 pi0 = np.ones(self.M).astype(np.float32) # initial state distribution
31 A0 = np.random.randn(self.M, self.M).astype(np.float32) # state transition matrix
32 R0 = np.ones((self.M, self.K)).astype(np.float32) # mixture proportions
33 # mu0 = np.random.randn(self.M, self.K, self.D).astype(np.float32)
34
35 mu0 = np.zeros((self.M, self.K, self.D))
36 for j in range(self.M):
37 for k in range(self.K):
38 n = np.random.randint(X.shape[0])
39 t = np.random.randint(X.shape[1])
40 mu0[j,k] = X[n,t]
41 mu0 = mu0.astype(np.float32)
42
43 sigma0 = np.random.randn(self.M, self.K, self.D).astype(np.float32)
44 self.build(pi0, A0, R0, mu0, sigma0)
45
46 def build(self, preSoftmaxPi, preSoftmaxA, preSoftmaxR, mu, logSigma):
47 self.preSoftmaxPi = tf.Variable(preSoftmaxPi)

Callers 2

real_signalFunction · 0.95
fake_signalFunction · 0.95

Calls 1

buildMethod · 0.95

Tested by

no test coverage detected