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

Method update

rl2/cartpole/td_lambda.py:62–75  ·  view source on GitHub ↗
(self, s, a, G, gamma, lambda_)

Source from the content-addressed store, hash-verified

60 return result
61
62 def update(self, s, a, G, gamma, lambda_):
63 X = self.feature_transformer.transform([s])
64 # assert(len(X.shape) == 2)
65
66 # slower
67 # for action in range(self.env.action_space.n):
68 # if action != a:
69 # self.eligibilities[action] *= gamma*lambda_
70 # else:
71 # self.eligibilities[a] = grad + gamma*lambda_*self.eligibilities[a]
72
73 self.eligibilities *= gamma*lambda_
74 self.eligibilities[a] += X[0]
75 self.models[a].partial_fit(X[0], G, self.eligibilities[a])
76
77 def sample_action(self, s, eps):
78 if np.random.random() < eps:

Callers 1

play_oneFunction · 0.45

Calls 2

transformMethod · 0.45
partial_fitMethod · 0.45

Tested by

no test coverage detected