Skip to main content

Blog (Tech)

PyTorch: Why view() fails after transpose()

transpose() makes tensors non-contiguous (logical ≠ physical order). view() only works with contiguous tensors → RuntimeError. Solution: Use reshape() instead of view()!

10/31/2025