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


Python segment_tree.MinSegmentTree方法代码示例

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


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

示例1: __init__

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def __init__(self,
                 limit,
                 alpha,
                 transition_small_epsilon=1e-6,
                 demo_epsilon=0.2,
                 nb_rollout_steps=100):
        super(PrioritizedMemory, self).__init__(limit, nb_rollout_steps)
        assert alpha > 0
        self._alpha = alpha
        self._transition_small_epsilon = transition_small_epsilon
        self._demo_epsilon = demo_epsilon
        it_capacity = 1
        while it_capacity < self.maxsize:
            it_capacity *= 2  # Size must be power of 2
        self._it_sum = SumSegmentTree(it_capacity)
        self._it_min = MinSegmentTree(it_capacity)
        self._max_priority = 1.0 
开发者ID:JanMatas,项目名称:Rainbow_ddpg,代码行数:19,代码来源:prioritized_memory.py

示例2: __init__

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def __init__(self, size, alpha, epsilon, timesteps, initial_p, final_p):
        super(DoublePrioritizedReplayBuffer, self).__init__(size)
        assert alpha > 0
        self._alpha = alpha
        self._epsilon = epsilon
        self._beta_schedule = LinearSchedule(timesteps, initial_p=initial_p, final_p=final_p)
        it_capacity = 1
        while it_capacity < size:
            it_capacity *= 2

        self._it_sum = SumSegmentTree(it_capacity)
        self._it_min = MinSegmentTree(it_capacity)
        self._max_priority = 1.0

        self._it_sum2 = SumSegmentTree(it_capacity)
        self._it_min2 = MinSegmentTree(it_capacity)
        self._max_priority2 = 1.0 
开发者ID:fabiopardo,项目名称:qmap,代码行数:19,代码来源:replay_buffers.py

示例3: __init__

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def __init__(self, size, alpha):
        """Create Prioritized Replay buffer.
        Parameters
        ----------
        size: int
            Max number of transitions to store in the buffer. When the buffer
            overflows the old memories are dropped.
        alpha: float
            how much prioritization is used
            (0 - no prioritization, 1 - full prioritization)
        See Also
        --------
        ReplayBuffer.__init__
        """
        super(PrioritizedReplayBuffer, self).__init__(size)
        assert alpha > 0
        self._alpha = alpha

        it_capacity = 1
        while it_capacity < size:
            it_capacity *= 2

        self._it_sum = SumSegmentTree(it_capacity)
        self._it_min = MinSegmentTree(it_capacity)
        self._max_priority = 1.0 
开发者ID:junhyukoh,项目名称:self-imitation-learning,代码行数:27,代码来源:self_imitation.py

示例4: __init__

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def __init__(self, size, alpha):
        """Create Prioritized Replay buffer.

        Parameters
        ----------
        size: int
            Max number of transitions to store in the buffer. When the buffer
            overflows the old memories are dropped.
        alpha: float
            how much prioritization is used
            (0 - no prioritization, 1 - full prioritization)

        See Also
        --------
        ReplayBuffer.__init__
        """
        super(PrioritizedReplayBuffer, self).__init__(size)
        assert alpha > 0
        self._alpha = alpha

        it_capacity = 1
        while it_capacity < size:
            it_capacity *= 2

        self._it_sum = SumSegmentTree(it_capacity)
        self._it_min = MinSegmentTree(it_capacity)
        self._max_priority = 1.0 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:29,代码来源:replay_buffer.py

示例5: test_max_interval_tree

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def test_max_interval_tree():
    tree = MinSegmentTree(4)

    tree[0] = 1.0
    tree[2] = 0.5
    tree[3] = 3.0

    assert np.isclose(tree.min(), 0.5)
    assert np.isclose(tree.min(0, 2), 1.0)
    assert np.isclose(tree.min(0, 3), 0.5)
    assert np.isclose(tree.min(0, -1), 0.5)
    assert np.isclose(tree.min(2, 4), 0.5)
    assert np.isclose(tree.min(3, 4), 3.0)

    tree[2] = 0.7

    assert np.isclose(tree.min(), 0.7)
    assert np.isclose(tree.min(0, 2), 1.0)
    assert np.isclose(tree.min(0, 3), 0.7)
    assert np.isclose(tree.min(0, -1), 0.7)
    assert np.isclose(tree.min(2, 4), 0.7)
    assert np.isclose(tree.min(3, 4), 3.0)

    tree[2] = 4.0

    assert np.isclose(tree.min(), 1.0)
    assert np.isclose(tree.min(0, 2), 1.0)
    assert np.isclose(tree.min(0, 3), 1.0)
    assert np.isclose(tree.min(0, -1), 1.0)
    assert np.isclose(tree.min(2, 4), 3.0)
    assert np.isclose(tree.min(2, 3), 4.0)
    assert np.isclose(tree.min(2, -1), 4.0)
    assert np.isclose(tree.min(3, 4), 3.0) 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:35,代码来源:test_segment_tree.py

示例6: __init__

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def __init__(self, size, alpha):
        """Create Prioritized Replay buffer.

        Parameters
        ----------
        size: int
            Max number of transitions to store in the buffer. When the buffer
            overflows the old memories are dropped.
        alpha: float
            how much prioritization is used
            (0 - no prioritization, 1 - full prioritization)

        See Also
        --------
        ReplayBuffer.__init__
        """
        super(PrioritizedReplayBuffer, self).__init__(size)
        assert alpha >= 0
        self._alpha = alpha

        it_capacity = 1
        while it_capacity < size:
            it_capacity *= 2

        self._it_sum = SumSegmentTree(it_capacity)
        self._it_min = MinSegmentTree(it_capacity)
        self._max_priority = 1.0 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:29,代码来源:replay_buffer.py

示例7: __init__

# 需要导入模块: from baselines.common import segment_tree [as 别名]
# 或者: from baselines.common.segment_tree import MinSegmentTree [as 别名]
def __init__(self, size, alpha):
        super(PrioritizedReplayBuffer, self).__init__(size)
        assert alpha > 0
        self._alpha = alpha
        it_capacity = 1
        while it_capacity < size:
            it_capacity *= 2
        self._it_sum = SumSegmentTree(it_capacity)
        self._it_min = MinSegmentTree(it_capacity)
        self._max_priority = 1.0 
开发者ID:TianhongDai,项目名称:self-imitation-learning-pytorch,代码行数:12,代码来源:sil_module.py


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