相同之處
- 都可以用來重新調整 tensor 的形狀。
不同之處
- view 函數只能用於 contiguous 後的 tensor 上,也就是隻能用於內存中連續存儲的 tensor。如果對 tensor 調用過 transpose, permute 等操作的話會使該 tensor 在內存中變得不再連續,此時就不能再調用 view 函數。因此,需要先使用 contiguous 來返回一個 contiguous copy。
- reshape 則不需要依賴目標 tensor 是否在內存中是連續的。
繼續運行 ?* 回憶上次內容 上次使用shell環境中的命令 命令 作用 c