Resize PyTorch Tensor

前端 未结 3 1199
醉梦人生
醉梦人生 2021-01-18 10:27

I am currently using the tensor.resize() function to resize a tensor to a new shape t = t.resize(1, 2, 3).

This gives me a deprecation warning:

3条回答
  •  醉酒成梦
    2021-01-18 11:17

    Please can you try something like:

    import torch
    x = torch.tensor([[1, 2], [3, 4], [5, 6]])
    print(":::",x.resize_(2, 2))
    print("::::",x.resize_(3, 3))
    

提交回复
热议问题