Live Engine
Select Topic
easyPytorch Fundamentals
A developer creates a PyTorch tensor from a NumPy array and then modifies the NumPy array. What happens to the tensor?
Code
import numpy as np
import torch
arr = np.array([1.0, 2.0, 3.0])
t = torch.from_numpy(arr)
arr[0] = 99.0
print(t)