本文整理汇总了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
示例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
示例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))
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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))
示例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))