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


Python cupy.concatenate方法代码示例

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


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

示例1: test_02

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_02(self):
        D = cp.random.randn(4, 4, 32)
        s = cp.random.randn(8, 8)
        Wg = cp.concatenate((cp.eye(16), cp.eye(16)), axis=-1)
        lmbda = 0.1

        # ConvBPDNInhib class
        opt = cbpdnin.ConvBPDNInhib.Options(
            {'Verbose': False, 'MaxMainIter': 10})

        try:
            b = cbpdnin.ConvBPDNInhib(D, s, Wg=Wg, lmbda=lmbda, opt=opt)
            b.solve()
        except Exception as e:
            print(e)
            assert 0 
开发者ID:bwohlberg,项目名称:sporco,代码行数:18,代码来源:test_cbpdnin.py

示例2: test_05

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_05(self):
        D = cp.random.randn(4, 32)
        s = cp.random.randn(64)
        Wg = np.concatenate((cp.eye(16), cp.eye(16)), axis=-1)
        lmbda = 0.1
        mu = 0.01
        gamma = 0.01

        # ConvBPDNInhib class
        opt = cbpdnin.ConvBPDNInhib.Options(
            {'Verbose': False, 'MaxMainIter': 10})

        try:
            b = cbpdnin.ConvBPDNInhib(
                D, s, Wg=Wg, lmbda=lmbda, mu=mu, gamma=gamma, opt=opt, dimN=1)
            b.solve()
        except Exception as e:
            print(e)
            assert 0 
开发者ID:bwohlberg,项目名称:sporco,代码行数:21,代码来源:test_cbpdnin.py

示例3: _compressed_sparse_stack

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def _compressed_sparse_stack(blocks, axis):
    """Fast path for stacking CSR/CSC matrices
    (i) vstack for CSR, (ii) hstack for CSC.
    """
    other_axis = 1 if axis == 0 else 0
    data = cupy.concatenate([b.data for b in blocks])
    constant_dim = blocks[0].shape[other_axis]
    idx_dtype = sputils.get_index_dtype(arrays=[b.indptr for b in blocks],
                                        maxval=max(data.size, constant_dim))
    indices = cupy.empty(data.size, dtype=idx_dtype)
    indptr = cupy.empty(sum(b.shape[axis]
                            for b in blocks) + 1, dtype=idx_dtype)
    last_indptr = idx_dtype(0)
    sum_dim = 0
    sum_indices = 0
    for b in blocks:
        if b.shape[other_axis] != constant_dim:
            raise ValueError(
                'incompatible dimensions for axis %d' % other_axis)
        indices[sum_indices:sum_indices+b.indices.size] = b.indices
        sum_indices += b.indices.size
        idxs = slice(sum_dim, sum_dim + b.shape[axis])
        indptr[idxs] = b.indptr[:-1]
        indptr[idxs] += last_indptr
        sum_dim += b.shape[axis]
        last_indptr += b.indptr[-1]
    indptr[-1] = last_indptr
    if axis == 0:
        return csr.csr_matrix((data, indices, indptr),
                              shape=(sum_dim, constant_dim))
    else:
        return csc.csc_matrix((data, indices, indptr),
                              shape=(constant_dim, sum_dim)) 
开发者ID:cupy,项目名称:cupy,代码行数:35,代码来源:construct.py

示例4: test_concatenate1

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate1(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_reverse_arange((2, 3, 2), xp, dtype)
        c = testing.shaped_arange((2, 3, 3), xp, dtype)
        return xp.concatenate((a, b, c), axis=2) 
开发者ID:cupy,项目名称:cupy,代码行数:7,代码来源:test_join.py

示例5: test_concatenate2

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate2(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_reverse_arange((2, 3, 2), xp, dtype)
        c = testing.shaped_arange((2, 3, 3), xp, dtype)
        return xp.concatenate((a, b, c), axis=-1) 
开发者ID:cupy,项目名称:cupy,代码行数:7,代码来源:test_join.py

示例6: test_concatenate_axis_none

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_axis_none(self, xp, dtype):
        a = testing.shaped_arange((2, 3), xp, dtype)
        b = testing.shaped_reverse_arange((3, 5, 2), xp, dtype)
        c = testing.shaped_arange((7, ), xp, dtype)
        return xp.concatenate((a, b, c), axis=None) 
开发者ID:cupy,项目名称:cupy,代码行数:7,代码来源:test_join.py

示例7: test_concatenate_large_2

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_large_2(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_reverse_arange((2, 3, 2), xp, dtype)
        c = testing.shaped_arange((2, 3, 3), xp, dtype)
        d = testing.shaped_arange((2, 3, 5), xp, dtype)
        e = testing.shaped_arange((2, 3, 2), xp, dtype)
        return xp.concatenate((a, b, c, d, e) * 2, axis=-1) 
开发者ID:cupy,项目名称:cupy,代码行数:9,代码来源:test_join.py

示例8: test_concatenate_large_4

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_large_4(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_reverse_arange((2, 3, 4), xp, dtype)
        return xp.concatenate((a, b) * 10, axis=-1) 
开发者ID:cupy,项目名称:cupy,代码行数:6,代码来源:test_join.py

示例9: test_concatenate_large_5

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_large_5(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_reverse_arange((2, 3, 4), xp, 'i')
        return xp.concatenate((a, b) * 10, axis=-1) 
开发者ID:cupy,项目名称:cupy,代码行数:6,代码来源:test_join.py

示例10: test_concatenate_large_different_devices

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_large_different_devices(self):
        arrs = []
        for i in range(10):
            with cuda.Device(i % 2):
                arrs.append(cupy.empty((2, 3, 4)))
        with pytest.raises(ValueError):
            cupy.concatenate(arrs) 
开发者ID:cupy,项目名称:cupy,代码行数:9,代码来源:test_join.py

示例11: test_concatenate_f_contiguous

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_f_contiguous(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_arange((2, 3, 2), xp, dtype).T
        c = testing.shaped_arange((2, 3, 3), xp, dtype)
        return xp.concatenate((a, b, c), axis=-1) 
开发者ID:cupy,项目名称:cupy,代码行数:7,代码来源:test_join.py

示例12: test_concatenate_large_f_contiguous

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_large_f_contiguous(self, xp, dtype):
        a = testing.shaped_arange((2, 3, 4), xp, dtype)
        b = testing.shaped_arange((2, 3, 2), xp, dtype).T
        c = testing.shaped_arange((2, 3, 3), xp, dtype)
        d = testing.shaped_arange((2, 3, 2), xp, dtype).T
        e = testing.shaped_arange((2, 3, 2), xp, dtype)
        return xp.concatenate((a, b, c, d, e) * 2, axis=-1) 
开发者ID:cupy,项目名称:cupy,代码行数:9,代码来源:test_join.py

示例13: test_concatenate_32bit_boundary

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_32bit_boundary(self):
        a = cupy.zeros((2 ** 30,), dtype=cupy.int8)
        b = cupy.zeros((2 ** 30,), dtype=cupy.int8)
        ret = cupy.concatenate([a, b])
        del a
        del b
        del ret
        # Free huge memory for slow test
        cupy.get_default_memory_pool().free_all_blocks() 
开发者ID:cupy,项目名称:cupy,代码行数:11,代码来源:test_join.py

示例14: test_concatenate_wrong_ndim

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_wrong_ndim(self):
        a = cupy.empty((2, 3))
        b = cupy.empty((2,))
        with self.assertRaises(ValueError):
            cupy.concatenate((a, b)) 
开发者ID:cupy,项目名称:cupy,代码行数:7,代码来源:test_join.py

示例15: test_concatenate_wrong_shape

# 需要导入模块: import cupy [as 别名]
# 或者: from cupy import concatenate [as 别名]
def test_concatenate_wrong_shape(self):
        a = cupy.empty((2, 3, 4))
        b = cupy.empty((3, 3, 4))
        c = cupy.empty((4, 4, 4))
        with self.assertRaises(ValueError):
            cupy.concatenate((a, b, c)) 
开发者ID:cupy,项目名称:cupy,代码行数:8,代码来源:test_join.py


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