MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / set

Method set

hmm_class/hmmd_theano.py:102–128  ·  view source on GitHub ↗
(self, pi, A, B)

Source from the content-addressed store, hash-verified

100 return np.array([self.get_cost(x) for x, p in zip(X, P) if p < p_cost])
101
102 def set(self, pi, A, B):
103 self.pi = theano.shared(pi)
104 self.A = theano.shared(A)
105 self.B = theano.shared(B)
106
107 # define cost
108 thx = T.ivector('thx')
109 def recurrence(t, old_a, x):
110 a = old_a.dot(self.A) * self.B[:, x[t]]
111 s = a.sum()
112 return (a / s), s
113
114 [alpha, scale], _ = theano.scan(
115 fn=recurrence,
116 sequences=T.arange(1, thx.shape[0]),
117 outputs_info=[self.pi*self.B[:,thx[0]], None],
118 n_steps=thx.shape[0]-1,
119 non_sequences=thx
120 )
121
122 cost = -T.log(scale).sum()
123 self.cost_op = theano.function(
124 inputs=[thx],
125 outputs=cost,
126 allow_input_downcast=True,
127 )
128 return thx, cost
129
130
131def fit_coin():

Callers 2

fitMethod · 0.95
fit_coinFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected