每周碎片知识42

[Pytorch]

reshape与view的区别:
reshape会尽量返回原tensor,若没办法返回原tensor则会copy一个新的tensor再做reshape;而view能保证返回的tensor和原来的tensor共享底层数据,但只能在contiguous的数据上用。

https://discuss.pytorch.org/t/in-pytorch-0-4-is-it-recommended-to-use-reshape-than-view-when-it-is-possible/17034/2