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


Python spaces.Discrete方法代码示例

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


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

示例1: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def __init__(
            self,
            env_spec,
            hidden_sizes=(32, 32),
            hidden_nonlinearity=NL.tanh,
            output_b_init=None,
            weight_signal=1.0,
            weight_nonsignal=1.0, 
            weight_smc=1.0):
        """
        :param env_spec: A spec for the mdp.
        :param hidden_sizes: list of sizes for the fully connected hidden layers
        :param hidden_nonlinearity: nonlinearity used for each hidden layer
        :return:
        """
        Serializable.quick_init(self, locals())
        assert isinstance(env_spec.action_space, Discrete)
        output_b_init = compute_output_b_init(env_spec.action_space.names,
            output_b_init, weight_signal, weight_nonsignal, weight_smc)

        prob_network = MLP(
            input_shape=(env_spec.observation_space.flat_dim,),
            output_dim=env_spec.action_space.n,
            hidden_sizes=hidden_sizes,
            hidden_nonlinearity=hidden_nonlinearity,
            output_nonlinearity=NL.softmax,
            output_b_init=output_b_init
        )
        super(InitCategoricalMLPPolicy, self).__init__(env_spec, hidden_sizes,
            hidden_nonlinearity, prob_network)


# Modified from RLLab GRUNetwork 
开发者ID:vicariousinc,项目名称:pixelworld,代码行数:35,代码来源:init_policy.py

示例2: ensure_named

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def ensure_named(space):
    """Ensure that the give space is named."""
    if isinstance(space, (NamedBox, NamedDiscrete)):
        return space
    elif isinstance(space, Box):
        return NamedBox.from_unnamed(space)
    elif isinstance(space, Discrete):
        return NamedDiscrete.from_unnamed(space)
#    elif isinstance(space, ListSpace):
#        return NamedDiscrete(len(space._list), names=space._list)        
    else:
        raise Exception("Cannot convert space of type %s into a named rllab space"
            % (type(space),)) 
开发者ID:vicariousinc,项目名称:pixelworld,代码行数:15,代码来源:spaces_rllab.py

示例3: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def __init__(self, transition_matrix, reward, init_state, terminate_on_reward=False):
        super(DiscreteEnv, self).__init__()
        dX, dA, dXX = transition_matrix.shape
        self.nstates = dX
        self.nactions = dA
        self.transitions = transition_matrix
        self.init_state = init_state
        self.reward = reward
        self.terminate_on_reward = terminate_on_reward

        self.__observation_space = Box(0, 1, shape=(self.nstates,))
        #max_A = 0
        #for trans in self.transitions:
        #    max_A = max(max_A, len(self.transitions[trans]))
        self.__action_space = Discrete(dA) 
开发者ID:justinjfu,项目名称:inverse_rl,代码行数:17,代码来源:simple_env.py

示例4: action_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def action_space(self):
        return spaces.Discrete(4) 
开发者ID:sisl,项目名称:hgail,代码行数:4,代码来源:new_env.py

示例5: observation_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def observation_space(self):
        return spaces.Product([spaces.Discrete(self.numrow),spaces.Discrete(self.numcol),spaces.Discrete(2)]) 
开发者ID:sisl,项目名称:hgail,代码行数:4,代码来源:new_env.py

示例6: action_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def action_space(self):
        return spaces.Discrete(2) 
开发者ID:sisl,项目名称:hgail,代码行数:4,代码来源:envs.py

示例7: observation_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def observation_space(self):
        return spaces.Discrete(3) 
开发者ID:sisl,项目名称:hgail,代码行数:4,代码来源:envs.py

示例8: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def __init__(self, ns):
        self.agent_num = len(ns)
        self.agent_spaces = np.array([Discrete(n) for n in ns]) 
开发者ID:ml3705454,项目名称:mapr2,代码行数:5,代码来源:space.py

示例9: action_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def action_space(self):
        lat_dim = self.low_policy_latent_dim
        if self.discrete_actions:
            return spaces.Discrete(lat_dim)  # the action is now just a selection
        else:
            ub = 1e6 * np.ones(lat_dim)
            return spaces.Box(-1 * ub, ub) 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:9,代码来源:hierarchized_snn_env.py

示例10: action_space

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def action_space(self):
        selector_dim = self.low_policy_selector_dim
        if self.discrete_actions:
            return spaces.Discrete(selector_dim)  # the action is now just a selection
        else:
            ub = 1e6 * np.ones(selector_dim)
            return spaces.Box(-1 * ub, ub) 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:9,代码来源:hierarchized_multiPol_env.py

示例11: __init__

# 需要导入模块: from rllab import spaces [as 别名]
# 或者: from rllab.spaces import Discrete [as 别名]
def __init__(
            self,
            env_spec,
            latent_dim=0,    # all this is fake
            latent_name='categorical',
            bilinear_integration=False,
            resample=False,  # until here
            hidden_sizes=(32, 32),
            hidden_nonlinearity=NL.tanh,
            prob_network=None,
    ):
        """
        :param env_spec: A spec for the mdp.
        :param hidden_sizes: list of sizes for the fully connected hidden layers
        :param hidden_nonlinearity: nonlinearity used for each hidden layer
        :param prob_network: manually specified network for this policy, other network params
        are ignored
        :return:
        """
        #bullshit
        self.latent_dim = latent_dim  ##could I avoid needing this self for the get_action?
        self.latent_name = latent_name
        self.bilinear_integration = bilinear_integration
        self.resample = resample
        self._set_std_to_0 = False

        Serializable.quick_init(self, locals())

        assert isinstance(env_spec.action_space, Discrete)

        if prob_network is None:
            prob_network = MLP(
                input_shape=(env_spec.observation_space.flat_dim,),
                output_dim=env_spec.action_space.n,
                hidden_sizes=hidden_sizes,
                hidden_nonlinearity=hidden_nonlinearity,
                output_nonlinearity=NL.softmax,
            )

        self._l_prob = prob_network.output_layer
        self._l_obs = prob_network.input_layer
        self._f_prob = ext.compile_function([prob_network.input_layer.input_var], L.get_output(
            prob_network.output_layer))

        self._dist = Categorical(env_spec.action_space.n)

        super(CategoricalMLPPolicy, self).__init__(env_spec)
        LasagnePowered.__init__(self, [prob_network.output_layer]) 
开发者ID:florensacc,项目名称:snn4hrl,代码行数:50,代码来源:categorical_mlp_policy.py


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