torch.Tensor.expand(*size)
paddle.Tensor.expand(shape, name=None)
两者功能一致,仅参数名不一致,具体差异如下:
| PyTorch | PaddlePaddle | 备注 | | ————- | ———— | —————————————————— | | size | shape | 扩张后的维度,size 是可变参数,paddle 是 list/tuple |
# torch 写法 x.expand(3, 4) # paddle 写法 x.expand(shape=[3, 4])