• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python parameters.LazyArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyNN.parameters.LazyArray的典型用法代码示例。如果您正苦于以下问题:Python LazyArray类的具体用法?Python LazyArray怎么用?Python LazyArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_columnwise_iteration_with_structured_array_and_mask

def test_columnwise_iteration_with_structured_array_and_mask():
    input = np.arange(12).reshape((4, 3))
    m = LazyArray(input, shape=(4, 3))  # 4 rows, 3 columns
    mask = np.array([False, True, True])
    cols = [col for col in m.by_column(mask=mask)]
    assert_array_equal(cols[0], input[:, 1])
    assert_array_equal(cols[1], input[:, 2])
开发者ID:JoelChavas,项目名称:PyNN,代码行数:7,代码来源:test_parameters.py


示例2: test_columnwise_iteration_with_function

def test_columnwise_iteration_with_function():
    input = lambda i, j: 2 * i + j
    m = LazyArray(input, shape=(4, 3))
    cols = [col for col in m.by_column()]
    assert_array_equal(cols[0], np.array([0, 2, 4, 6]))
    assert_array_equal(cols[1], np.array([1, 3, 5, 7]))
    assert_array_equal(cols[2], np.array([2, 4, 6, 8]))
开发者ID:JoelChavas,项目名称:PyNN,代码行数:7,代码来源:test_parameters.py


示例3: test_multiple_operations_with_structured_array

def test_multiple_operations_with_structured_array():
    input = np.arange(12).reshape((4, 3))
    m0 = LazyArray(input, shape=(4, 3))
    m1 = (m0 + 2) < 5
    m2 = (m0 < 5) + 2
    assert_array_equal(m1.evaluate(simplify=True), (input + 2) < 5)
    assert_array_equal(m2.evaluate(simplify=True), (input < 5) + 2)
    assert_array_equal(m0.evaluate(simplify=True), input)
开发者ID:JoelChavas,项目名称:PyNN,代码行数:8,代码来源:test_parameters.py


示例4: test_evaluate_with_functional_array

def test_evaluate_with_functional_array():
    input = lambda i,j: 2*i + j
    m = LazyArray(input, shape=(4,3))
    assert_array_equal(m.evaluate(),
                        np.array([[0, 1, 2],
                                     [2, 3, 4],
                                     [4, 5, 6],
                                     [6, 7, 8]]))
开发者ID:bernhardkaplan,项目名称:PyNN,代码行数:8,代码来源:test_parameters.py


示例5: test_columnwise_iteration_with_random_array_parallel_safe_no_mask

def test_columnwise_iteration_with_random_array_parallel_safe_no_mask():
    random.mpi_rank=0; random.num_processes=2
    input = random.RandomDistribution(rng=MockRNG(parallel_safe=True))
    copy_input = random.RandomDistribution(rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4,3))
    cols = [col for col in m.by_column()]
    assert_array_equal(cols[0], copy_input.next(4, mask_local=False))
    assert_array_equal(cols[1], copy_input.next(4, mask_local=False))
    assert_array_equal(cols[2], copy_input.next(4, mask_local=False))
开发者ID:bernhardkaplan,项目名称:PyNN,代码行数:9,代码来源:test_parameters.py


示例6: test_columnwise_iteration_with_random_array_parallel_safe_with_mask

def test_columnwise_iteration_with_random_array_parallel_safe_with_mask():
    random.mpi_rank=0; random.num_processes=2
    input = random.RandomDistribution(rng=MockRNG(parallel_safe=True))
    copy_input = random.RandomDistribution(rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4,3))
    mask = np.array([False, False, True])
    cols = [col for col in m.by_column(mask=mask)]
    assert_equal(len(cols), 1)
    assert_array_almost_equal(cols[0], copy_input.next(12, mask_local=False)[8:], 15)
开发者ID:bernhardkaplan,项目名称:PyNN,代码行数:9,代码来源:test_parameters.py


示例7: test_columnwise_iteration_with_random_array_parallel_safe_with_mask

def test_columnwise_iteration_with_random_array_parallel_safe_with_mask():
    orig_get_mpi_config = random.get_mpi_config
    random.get_mpi_config = lambda: (0, 2)
    input = random.RandomDistribution("uniform", (0, 1), rng=MockRNG(parallel_safe=True))
    copy_input = random.RandomDistribution("gamma", (2, 3), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    mask = np.array([False, False, True])
    cols = [col for col in m.by_column(mask=mask)]
    assert_equal(len(cols), 1)
    assert_array_almost_equal(cols[0], copy_input.next(12, mask_local=False)[8:], 15)
    random.get_mpi_config = orig_get_mpi_config
开发者ID:JoelChavas,项目名称:PyNN,代码行数:11,代码来源:test_parameters.py


示例8: test_columnwise_iteration_with_random_array_parallel_safe_no_mask

def test_columnwise_iteration_with_random_array_parallel_safe_no_mask():
    orig_get_mpi_config = random.get_mpi_config
    random.get_mpi_config = lambda: (0, 2)
    input = random.RandomDistribution("uniform", (0, 1), rng=MockRNG(parallel_safe=True))
    copy_input = random.RandomDistribution("normal", (0, 1), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    cols = [col for col in m.by_column()]
    assert_array_equal(cols[0], copy_input.next(4, mask_local=False))
    assert_array_equal(cols[1], copy_input.next(4, mask_local=False))
    assert_array_equal(cols[2], copy_input.next(4, mask_local=False))
    random.get_mpi_config = orig_get_mpi_config
开发者ID:JoelChavas,项目名称:PyNN,代码行数:11,代码来源:test_parameters.py


示例9: test_columnwise_iteration_with_random_array_parallel_safe_no_mask

def test_columnwise_iteration_with_random_array_parallel_safe_no_mask():
    orig_get_mpi_config = random.get_mpi_config

    # first, with a single MPI node
    random.get_mpi_config = lambda: (0, 2)
    input = random.RandomDistribution('uniform', (0, 1), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    cols_np1 = [col for col in m.by_column()]

    # now, on one node of two
    random.get_mpi_config = lambda: (1, 2)
    input = random.RandomDistribution('uniform', (0, 1), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    cols_np2_1 = [col for col in m.by_column()]

    for i in range(3):
        assert_array_equal(cols_np1[i], cols_np2_1[i])

    random.get_mpi_config = orig_get_mpi_config
开发者ID:NeuralEnsemble,项目名称:PyNN,代码行数:19,代码来源:test_parameters.py


示例10: test_columnwise_iteration_with_random_array_parallel_safe_with_mask

def test_columnwise_iteration_with_random_array_parallel_safe_with_mask():
    orig_get_mpi_config = random.get_mpi_config

    mask = np.array([False, False, True])

    # first, with a single MPI node
    random.get_mpi_config = lambda: (0, 2)
    input = random.RandomDistribution('uniform', (0, 1), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    cols_np1 = [col for col in m.by_column(mask=mask)]

    # now, on one node of two
    random.get_mpi_config = lambda: (0, 2)
    input = random.RandomDistribution('uniform', (0, 1), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    cols_np2_0 = [col for col in m.by_column(mask=mask)]

    # now, on the other node of two
    random.get_mpi_config = lambda: (1, 2)
    input = random.RandomDistribution('uniform', (0, 1), rng=MockRNG(parallel_safe=True))
    m = LazyArray(input, shape=(4, 3))
    cols_np2_1 = [col for col in m.by_column(mask=mask)]

    assert_equal(len(cols_np1), 1)
    assert_equal(len(cols_np2_0), 1)
    assert_equal(len(cols_np2_1), 1)
    assert_array_equal(cols_np1[0], cols_np2_0[0])

    random.get_mpi_config = orig_get_mpi_config
开发者ID:NeuralEnsemble,项目名称:PyNN,代码行数:29,代码来源:test_parameters.py


示例11: test_columnwise_iteration_with_structured_array

def test_columnwise_iteration_with_structured_array():
    input = np.arange(12).reshape((4, 3))
    m = LazyArray(input, shape=(4, 3))  # 4 rows, 3 columns
    cols = [col for col in m.by_column()]
    assert_array_equal(cols[0], input[:, 0])
    assert_array_equal(cols[2], input[:, 2])
开发者ID:JoelChavas,项目名称:PyNN,代码行数:6,代码来源:test_parameters.py


示例12: test_evaluate_with_structured_array

def test_evaluate_with_structured_array():
    input = np.arange(12).reshape((4, 3))
    m = LazyArray(input, shape=(4, 3))
    assert_array_equal(m.evaluate(), input)
开发者ID:JoelChavas,项目名称:PyNN,代码行数:4,代码来源:test_parameters.py


示例13: test_setitem_nonexpanded_different_value

def test_setitem_nonexpanded_different_value():
    A = LazyArray(3, shape=(5,))
    assert A.evaluate(simplify=True) == 3
    A[0] = 4
    A[4] = 5
    assert_array_equal(A.evaluate(simplify=True), np.array([4, 3, 3, 3, 5]))
开发者ID:JoelChavas,项目名称:PyNN,代码行数:6,代码来源:test_parameters.py


示例14: test_columnwise_iteration_with_flat_array

def test_columnwise_iteration_with_flat_array():
    m = LazyArray(5, shape=(4, 3))  # 4 rows, 3 columns
    cols = [col for col in m.by_column()]
    assert_equal(cols, [5, 5, 5])
开发者ID:JoelChavas,项目名称:PyNN,代码行数:4,代码来源:test_parameters.py


示例15: test_create_with_array

def test_create_with_array():
    A = LazyArray(np.array([1, 2, 3]), shape=(3,))
    assert A.shape == (3,)
    assert_array_equal(A.evaluate(simplify=True), np.array([1, 2, 3]))
开发者ID:JoelChavas,项目名称:PyNN,代码行数:4,代码来源:test_parameters.py


示例16: test_setitem_nonexpanded_same_value

def test_setitem_nonexpanded_same_value():
    A = LazyArray(3, shape=(5,))
    assert A.evaluate(simplify=True) == 3
    A[0] = 3
    assert A.evaluate(simplify=True) == 3
开发者ID:JoelChavas,项目名称:PyNN,代码行数:5,代码来源:test_parameters.py


示例17: test_create_with_float

def test_create_with_float():
    A = LazyArray(3.0, shape=(5,))
    assert A.shape == (5,)
    assert A.evaluate(simplify=True) == 3.0
开发者ID:JoelChavas,项目名称:PyNN,代码行数:4,代码来源:test_parameters.py


示例18: test_columnwise_iteration_with_flat_array_and_mask

def test_columnwise_iteration_with_flat_array_and_mask():
    m = LazyArray(5, shape=(4, 3))  # 4 rows, 3 columns
    mask = np.array([True, False, True])
    cols = [col for col in m.by_column(mask=mask)]
    assert_equal(cols, [5, 5])
开发者ID:JoelChavas,项目名称:PyNN,代码行数:5,代码来源:test_parameters.py


示例19: test_lt_with_flat_array

def test_lt_with_flat_array():
    m0 = LazyArray(5, shape=(4, 3))
    m1 = m0 < 10
    assert_equal(m1.evaluate(simplify=True), True)
    assert_equal(m0.evaluate(simplify=True), 5)
开发者ID:JoelChavas,项目名称:PyNN,代码行数:5,代码来源:test_parameters.py


示例20: test_iadd_with_flat_array

def test_iadd_with_flat_array():
    m = LazyArray(5, shape=(4, 3))
    m += 2
    assert_array_equal(m.evaluate(), 7 * np.ones((4, 3)))
    assert_equal(m.base_value, 5)
    assert_equal(m.evaluate(simplify=True), 7)
开发者ID:JoelChavas,项目名称:PyNN,代码行数:6,代码来源:test_parameters.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python parameters.ParameterSpace类代码示例发布时间:2022-05-25
下一篇:
Python neuron.setup函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap