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

Method fit

hmm_class/hmmc_tf.py:143–162  ·  view source on GitHub ↗
(self, X, max_iter=10)

Source from the content-addressed store, hash-verified

141 self.session.run([op1, op2, op3, op4, op5])
142
143 def fit(self, X, max_iter=10):
144 # train the HMM model using stochastic gradient descent
145
146 N = len(X)
147 print("number of train samples:", N)
148
149 costs = []
150 for it in range(max_iter):
151 if it % 1 == 0:
152 print("it:", it)
153
154 for n in range(N):
155 # this would of course be much faster if we didn't do this on
156 # every iteration of the loop
157 c = self.get_cost_multi(X).sum()
158 costs.append(c)
159 self.session.run(self.train_op, feed_dict={self.tfx: X[n]})
160
161 plt.plot(costs)
162 plt.show()
163
164 def get_cost(self, x):
165 return self.session.run(self.cost_op, feed_dict={self.tfx: x})

Callers 2

real_signalFunction · 0.95
fake_signalFunction · 0.95

Calls 2

get_cost_multiMethod · 0.95
runMethod · 0.45

Tested by

no test coverage detected