Skip to content

Incorrect Information in /00_pytorch_fundamentals.ipynb #1306

@Abhicoder1999

Description

@Abhicoder1999

In the section "PyTorch tensors & NumPy"

Image

The section mentions "if you change the original tensor, the new numpy_tensor stays the same" is incorrect.

by default, the .numpy() method creates a view (shared memory) of the PyTorch tensor's data, not a complete copy. The converted NumPy array will share the same underlying memory as the PyTorch tensor (if both are on the CPU). This means if you change the values in the NumPy array, the corresponding values in the PyTorch tensor will also change, and vice versa.

When you perform an arithmetic operation (like adding a scalar) to a tensor, the result is typically a new tensor created in a separate memory block. This operation is not a view, and it does not share memory with the original tensor. For this reason, changing the tensor in the section did not change the numpy_tensor.

Could go in depth into this inconsistency because of the practical approach in the module!
Thank you for teaching at some good depth!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions