Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replaced "from_numpy" with "as_tensor" in docs.#16587

Closed
sebftw wants to merge 1 commit into
pytorch:masterfrom
sebftw:patch-1
Closed

Replaced "from_numpy" with "as_tensor" in docs.#16587
sebftw wants to merge 1 commit into
pytorch:masterfrom
sebftw:patch-1

Conversation

@sebftw
Copy link
Copy Markdown
Contributor

@sebftw sebftw commented Jan 31, 2019

📚 Documentation

In the warning box on https://pytorch.org/docs/stable/tensors.html#torch.Tensor.new_tensor it says:

new_tensor() always copies data. [...] If you have a numpy array and want to avoid a copy, use torch.from_numpy().

But then further up the page we have another warning box with the message:

torch.tensor() always copies data. [...] If you have a numpy array and want to avoid a copy, use torch.as_tensor().

Now I believe this is just a small oversight, since from_numpy is to be deprecated in favour of as_tensor. See for example #6885 and #8611. I suggest to just use torch.as_tensor() in both of the warning boxes.

cc @gchanan

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
In the warning box on https://pytorch.org/docs/stable/tensors.html#torch.Tensor.new_tensor it says:

> new_tensor() always copies data. [...] If you have a numpy array and want to avoid a copy, use **torch.from_numpy()**.

But then further up the page we have another warning box with the message:

> torch.tensor() always copies data. [...] If you have a numpy array and want to avoid a copy, use **torch.as_tensor()**.

Now I believe this is just a small oversight, since from_numpy is to be deprecated in favour of as_tensor. See for example pytorch#6885 and pytorch#8611. I suggest to just use **torch.as_tensor()** in both of the warning boxes.

cc gchanan
Pull Request resolved: pytorch#16587

Differential Revision: D13897038

Pulled By: gchanan

fbshipit-source-id: 2eb3cd47d2c0b5bf4350f980de3be9fe59b4a846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants