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

torch.repeat()

时间:2022-09-05 17:22:13浏览次数:47  
标签:repeat dimensions torch print size Size

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
From: https://www.cnblogs.com/wjune-0405/p/16658907.html

相关文章