其他分享
首页 > 其他分享> > torch.repeat()

torch.repeat()

作者:互联网

PyTorch中的repeat()函数可以对张量进行重复扩充。

>>> a= torch.arange(24).reshape(1,2,3,4)
>>> print(a.size())
torch.Size([1, 2, 3, 4])
>>> print("b.size",a.repeat(2,2,2,2).size())
b.size torch.Size([2, 4, 6, 8])
>>> print("b.size",a.repeat(2,2).size)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor

标签:repeat,dimensions,torch,print,size,Size
来源: https://www.cnblogs.com/wjune-0405/p/16658907.html