MCPcopy
hub / github.com/tensorlayer/TensorLayer / get_action

Method get_action

examples/reinforcement_learning/tutorial_DDPG.py:151–163  ·  view source on GitHub ↗

Choose action :param s: state :param greedy: get action greedy or not :return: act

(self, s, greedy=False)

Source from the content-addressed store, hash-verified

149 i.assign(self.ema.average(j))
150
151 def get_action(self, s, greedy=False):
152 """
153 Choose action
154 :param s: state
155 :param greedy: get action greedy or not
156 :return: act
157 """
158 a = self.actor(np.array([s], dtype=np.float32))[0]
159 if greedy:
160 return a
161 return np.clip(
162 np.random.normal(a, self.var), -self.action_range, self.action_range
163 ) # add randomness to action selection for exploration
164
165 def learn(self):
166 """

Callers 1

tutorial_DDPG.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected