當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。