numpy.tile(A, reps)"/>
numpy.tile(A, reps)
numpy.tile(A, reps)
Parameters:
A : The input array.
reps : The number of repetitions of A along each axis
import torch
import numpy as npx = torch.from_numpy(np.arange(4).reshape((1, 4)))print('tensor原型:', x)print('x沿着维度0复制2倍', np.tile(x, 2))
print('x沿着维度0、维度1,分别复制2倍、2倍', np.tile(x, (2, 2)))
print('x沿着维度0、维度1、维度2,分别复制2倍、2倍、2倍', np.tile(x, (2, 2, 2)))
代码运行结果:
tensor原型: tensor([[0, 1, 2, 3]])
x沿着维度0复制2倍 [[0 1 2 3 0 1 2 3]]
x沿着维度0、维度1,分别复制2倍、2倍 [[0 1 2 3 0 1 2 3][0 1 2 3 0 1 2 3]]
x沿着维度0、维度1、维度2,分别复制2倍、2倍、2倍 [[[0 1 2 3 0 1 2 3][0 1 2 3 0 1 2 3]][[0 1 2 3 0 1 2 3][0 1 2 3 0 1 2 3]]]
更多推荐
numpy.tile(A, reps)
发布评论