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


Python Wrapper.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False):
        Wrapper.__init__(self, env=env)
        self.tstart = time.time()
        if filename is None:
            self.f = None
            self.logger = None
        else:
            if not filename.endswith(Monitor.EXT):
                filename = filename + "." + Monitor.EXT
            self.f = open(filename, "wt")
            self.logger = JSONLogger(self.f)
            self.logger.writekvs({"t_start": self.tstart, "gym_version": gym.__version__,
                "env_id": env.spec.id if env.spec else 'Unknown'})
        self.allow_early_resets = allow_early_resets
        self.rewards = None
        self.needs_reset = True
        self.episode_rewards = []
        self.episode_lengths = []
        self.total_steps = 0
        self.current_metadata = {} # extra info that gets injected into each log entry
        # Useful for metalearning where we're modifying the environment externally
        # But want our logs to know about these modifications 
开发者ID:AdamStelmaszczyk,项目名称:learning2run,代码行数:24,代码来源:monitor.py

示例2: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, reset_keywords=(), info_keywords=()):
        Wrapper.__init__(self, env=env)
        self.tstart = time.time()
        self.results_writer = ResultsWriter(
            filename,
            header={"t_start": time.time(), 'env_id' : env.spec and env.spec.id},
            extra_keys=reset_keywords + info_keywords
        )
        self.reset_keywords = reset_keywords
        self.info_keywords = info_keywords
        self.allow_early_resets = allow_early_resets
        self.rewards = None
        self.needs_reset = True
        self.episode_rewards = []
        self.episode_lengths = []
        self.episode_times = []
        self.total_steps = 0
        self.current_reset_info = {} # extra info about the current episode, that was passed in during reset() 
开发者ID:hiwonjoon,项目名称:ICML2019-TREX,代码行数:20,代码来源:monitor.py

示例3: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, reset_keywords=(), info_keywords=()):
        Wrapper.__init__(self, env=env)
        self.tstart = time.time()
        if filename:
            self.results_writer = ResultsWriter(filename,
                header={"t_start": time.time(), 'env_id' : env.spec and env.spec.id},
                extra_keys=reset_keywords + info_keywords
            )
        else:
            self.results_writer = None
        self.reset_keywords = reset_keywords
        self.info_keywords = info_keywords
        self.allow_early_resets = allow_early_resets
        self.rewards = None
        self.needs_reset = True
        self.episode_rewards = []
        self.episode_lengths = []
        self.episode_times = []
        self.total_steps = 0
        self.current_reset_info = {} # extra info about the current episode, that was passed in during reset() 
开发者ID:openai,项目名称:baselines,代码行数:22,代码来源:monitor.py

示例4: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env):
        """Adds two qunatities to info returned by every step:

            num_steps: int
                Number of steps takes so far
            rewards: [float]
                All the cumulative rewards for the episodes completed so far.
        """
        super().__init__(env)
        # current episode state
        self._current_reward = None
        self._num_steps = None
        # temporary monitor state that we do not save
        self._time_offset = None
        self._total_steps = None
        # monitor state
        self._episode_rewards = []
        self._episode_lengths = []
        self._episode_end_times = [] 
开发者ID:cxxgtxy,项目名称:deeprl-baselines,代码行数:21,代码来源:monitor.py

示例5: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, reset_keywords=(), info_keywords=()):
        Wrapper.__init__(self, env=env)
        self.tstart = time.time()
        if filename is None:
            self.f = None
            self.logger = None
        else:
            if not filename.endswith(Monitor.EXT):
                if osp.isdir(filename):
                    filename = osp.join(filename, Monitor.EXT)
                else:
                    filename = filename + "." + Monitor.EXT
            self.f = open(filename, "wt")
            self.f.write('#%s\n'%json.dumps({"t_start": self.tstart, 'env_id' : env.spec and env.spec.id}))
            self.logger = csv.DictWriter(self.f, fieldnames=('r', 'l', 't')+reset_keywords+info_keywords)
            self.logger.writeheader()
            self.f.flush()

        self.reset_keywords = reset_keywords
        self.info_keywords = info_keywords
        self.allow_early_resets = allow_early_resets
        self.rewards = None
        self.needs_reset = True
        self.episode_rewards = []
        self.episode_lengths = []
        self.episode_times = []
        self.total_steps = 0
        self.current_reset_info = {} # extra info about the current episode, that was passed in during reset() 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:30,代码来源:monitor.py

示例6: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, reset_keywords=()):
        Wrapper.__init__(self, env=env)
        self.tstart = time.time()
        if filename is None:
            self.f = None
            self.logger = None
        else:
            if not filename.endswith(Monitor.EXT):
                if osp.isdir(filename):
                    filename = osp.join(filename, Monitor.EXT)
                else:
                    filename = filename + "." + Monitor.EXT
            self.f = open(filename, "wt")
            self.f.write('#%s\n'%json.dumps({"t_start": self.tstart, 'env_id' : env.spec and env.spec.id}))
            self.logger = csv.DictWriter(self.f, fieldnames=('r', 'l', 't')+reset_keywords)
            self.logger.writeheader()

        self.reset_keywords = reset_keywords
        self.allow_early_resets = allow_early_resets
        self.rewards = None
        self.needs_reset = True
        self.episode_rewards = []
        self.episode_lengths = []
        self.episode_times = []
        self.total_steps = 0
        self.current_reset_info = {} # extra info about the current episode, that was passed in during reset() 
开发者ID:vik-goel,项目名称:MOREL,代码行数:28,代码来源:monitor.py

示例7: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env, filename, allow_early_resets=False, cpu=None):
        Wrapper.__init__(self, env=env)
        self.tstart = time.time()
        self.filename = filename
        if filename is None:
            self.f = None
            self.logger = None
        else:
            if not filename.endswith(Monitor.EXT):
                filename_local = filename + "." + Monitor.EXT_LOCAL
                filename = filename + "." + Monitor.EXT
            else:
                filename_local = filename[:-13] + "." + Monitor.EXT_LOCAL
            self.f = open(filename, "wt")
            self.f_local = open(filename_local, "wt")
            self.logger = JSONLogger(self.f, filename=filename)
            self.logger_local = JSONLogger(self.f_local, override=True)
            self.logger.writekvs({"t_start": self.tstart, "gym_version": gym.__version__,
                                  "env_id": env.spec.id if env.spec else 'Unknown'})
            self.logger_local.writekvs({"t_start": self.tstart, "gym_version": gym.__version__,
                                        "env_id": env.spec.id if env.spec else 'Unknown'})
        self.allow_early_resets = allow_early_resets
        self.rewards = None
        self.needs_reset = True
        self.episode_rewards = []
        self.episode_lengths = []
        self.total_steps = 0
        self.current_metadata = {}  # extra info that gets injected into each log entry
        # Useful for metalearning where we're modifying the environment externally
        # But want our logs to know about these modifications

        self.cpu = cpu 
开发者ID:oxwhirl,项目名称:treeqn,代码行数:34,代码来源:monitor.py

示例8: __init__

# 需要导入模块: from gym.core import Wrapper [as 别名]
# 或者: from gym.core.Wrapper import __init__ [as 别名]
def __init__(self, env_fns):
        self.envs = [fn() for fn in env_fns]
        env = self.envs[0]
        self.action_space = env.action_space
        self.observation_space = env.observation_space
        self.ts = np.zeros(len(self.envs), dtype='int') 
开发者ID:borgwang,项目名称:reinforce_py,代码行数:8,代码来源:env_wrapper.py


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