[组合替代实现]torch.Size¶
转写示例¶
# PyTorch 写法
torch.Size([1])
# Paddle 写法
(1,)
# PyTorch 写法
torch.Size([2, 3])
# Paddle 写法
(2, 3)
# PyTorch 写法
torch.Size([2, 3]).count(2)
# Paddle 写法
(2, 3).count(2)
# PyTorch 写法
torch.Size([2, 3]).index(3,0)
# Paddle 写法
(2, 3).index(3,0)
# PyTorch 写法
torch.Size([2, 3]).numel()
# Paddle 写法
result = (2, 3)
out = 1
for x in result:
out *= x