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


Python core.Env方法代码示例

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


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

示例1: serialize

# 需要导入模块: from gym import core [as 别名]
# 或者: from gym.core import Env [as 别名]
def serialize(obj):
    """
        Serialize any object to a dictionary, so that it can be dumped easily to a JSON file.

     Four rules are applied:
        - To be able to recreate the object, specify its class, or its spec id if the object is an Env.
        - If the object has a config dictionary field, use it. It is assumed that this config suffices to recreate a
        similar object.
        - If the object is Serializable, use its recursive conversion to a dictionary.
        - Else, use its __dict__ by applying repr() on its values
    :param obj: an object
    :return: a dictionary describing the object
    """
    if hasattr(obj, "config"):
        d = obj.config
    elif isinstance(obj, Serializable):
        d = obj.to_dict()
    else:
        d = {key: repr(value) for (key, value) in obj.__dict__.items()}
    d['__class__'] = repr(obj.__class__)
    if isinstance(obj, Env):
        d['id'] = obj.spec.id
        d['import_module'] = getattr(obj, "import_module", None)
    return d 
开发者ID:eleurent,项目名称:rl-agents,代码行数:26,代码来源:configuration.py

示例2: __init__

# 需要导入模块: from gym import core [as 别名]
# 或者: from gym.core import Env [as 别名]
def __init__(self, task=None):
        super(Env, self).__init__()
        if task is None:
            task = self.sample_tasks(1)[0]
        self.set_task(task) 
开发者ID:learnables,项目名称:learn2learn,代码行数:7,代码来源:meta_env.py


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