添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
/usr/local/lib/python3.12/site-packages/torch/_subclasses/functional_tensor.py:295: UserWarning: Failed to initialize NumPy: No module named 'numpy' (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.)
  cpu = _conversion_method_template(device=torch.device("cpu"))

Why does the following code raise a runtime error, and what does that error mean?

permute() , it is also possible to create non-contiguous tensors:

reshape() method instead of view() to avoid the inconsistency between tensor shape and stride.

contiguous() method:

reshape() method is essentially a convenience method: It first checks whether a tensor is contiguous and then either returns a view (if it is) or converts the tensor into a contiguous copy by calling contiguous() .