問題文
A developer loads a NumPy array of features and wants a PyTorch tensor that shares the same underlying memory, so that no extra copy of a large array is made. Which call satisfies that requirement?
選択肢
- torch.from_numpy(array), which builds a tensor that shares memory with the array.
- torch.Tensor(array.shape), so a tensor of the same shape is allocated over the same buffer.
- torch.clone(array), which links the two objects so that a later write to either one is seen by both.
- torch.tensor(array), because the constructor is documented as the memory-sharing entry point for external array objects.