pytorch / tutorials

PyTorch tutorials.
https://pytorch.org/tutorials/
BSD 3-Clause "New" or "Revised" License
8.13k stars 4.04k forks source link

[BUG] - UserWarning: Using torch.cross without specifying the dim arg is deprecated. #2933

Closed njzjz closed 1 month ago

njzjz commented 3 months ago

Add Link

https://pytorch.org/tutorials/beginner/introyt/tensors_deeper_tutorial.html

Describe the bug

image

/var/lib/workspace/beginner_source/introyt/tensors_deeper_tutorial.py:462: UserWarning:

Using torch.cross without specifying the dim arg is deprecated.
Please either pass the dim explicitly or simply use torch.linalg.cross.
The default value of dim will change to agree with that of linalg.cross in a future release. (Triggered internally at ../aten/src/ATen/native/Cross.cpp:62.)

Describe your environment

I don't actually run it but find the web page has such a warning.

ignaciobartol commented 3 months ago

Hi, after checking on this bug, there are a few things that I noted here:

  1. While torch.cross is more flexible and allows you for more complex cross products, I believe the expected behavior is usually the one from torch.linalg.cross implementation. In this discussion it explains why blindly using torch.cross can lead you to an intersting bug-hunting.
  2. The function torch.svd is deprecated and will be removed in future pytorch release.

I am submitting a PR to attempt to solve this issue and updating the tutorial.