MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / recent_state

Method recent_state

examples/DeepQNetwork/expreplay.py:183–196  ·  view source on GitHub ↗

Get the recent state (with stacked history) of the environment. Returns: a list of ``hist_len-1`` elements, each of shape ``self.state_shape``

(self)

Source from the content-addressed store, hash-verified

181 self._current_episode.clear()
182
183 def recent_state(self):
184 """
185 Get the recent state (with stacked history) of the environment.
186
187 Returns:
188 a list of ``hist_len-1`` elements, each of shape ``self.state_shape``
189 """
190 expected_len = self.history_len - 1
191 if len(self._current_episode) >= expected_len:
192 return [k.state for k in self._current_episode[-expected_len:]]
193 else:
194 states = [np.zeros(self.state_shape, dtype=self.dtype)] * (expected_len - len(self._current_episode))
195 states.extend([k.state for k in self._current_episode])
196 return states
197
198
199class EnvRunnerManager(object):

Callers 1

stepMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected