当前位置: 首页>>代码示例>>Python>>正文


Python error.ResetNeeded方法代码示例

本文整理汇总了Python中gym.error.ResetNeeded方法的典型用法代码示例。如果您正苦于以下问题:Python error.ResetNeeded方法的具体用法?Python error.ResetNeeded怎么用?Python error.ResetNeeded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gym.error的用法示例。


在下文中一共展示了error.ResetNeeded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: step

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import ResetNeeded [as 别名]
def step(self, action):
        if not self.episode_number or self.timesteps is self.horizon:
            raise error.ResetNeeded()

        state = self._get_new_state()
        self._take_action(action)
        reward = self._get_reward()

        message = "Timestep {}:==: Action: {} ; Reward: {}".format(
            self.timesteps, CryptoEnv.action_space.lookup[action], reward
        )
        self.logger.debug(message)
        
        self.timesteps = self.timesteps + 1
        if self.timesteps is not self.horizon:
            self.current = self.current + 1
            return state, reward, False, np.array([float(self.horizon - self.timesteps) / self.horizon])
        else:
            return state, reward, True, np.array([0.0]) 
开发者ID:samre12,项目名称:gym-cryptotrading,代码行数:21,代码来源:weightedPnL.py

示例2: before_step

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import ResetNeeded [as 别名]
def before_step(self, action):
        assert not self.closed

        if self.done:
            raise error.ResetNeeded("Trying to step environment which is currently done. While the monitor is active for {}, you cannot step beyond the end of an episode. Call 'env.reset()' to start the next episode.".format(self.env_id))
        elif self.steps is None:
            raise error.ResetNeeded("Trying to step an environment before reset. While the monitor is active for {}, you must call 'env.reset()' before taking an initial step.".format(self.env_id)) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:9,代码来源:stats_recorder.py

示例3: _before_env_step

# 需要导入模块: from gym import error [as 别名]
# 或者: from gym.error import ResetNeeded [as 别名]
def _before_env_step(self, action):
    # Do not execute if the environment was not stepped or reset from this monitor
    if not self._active:
      # Remember that env was not stepped via the monitor and require reset next time
      self.stats_recorder.env_done = None
      return

    if self.done is None:
      raise ResetNeeded("Trying to step environment {}, before calling 'env.reset()'.".format(self.env_id))

    if self.done:
      raise ResetNeeded("Trying to step environment {}, which is done. You cannot step beyond the "
        "end of an episode. Call 'env.reset()' to start the next episode.".format(self.env_id)) 
开发者ID:nikonikolov,项目名称:rltf,代码行数:15,代码来源:monitor.py


注:本文中的gym.error.ResetNeeded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。