pytorch 中的view、reshape、permute、transpose、contiguous
1、 contiguous
https://stackoverflow.com/questions/48915810/pytorch-contiguous
https://blog.csdn.net/Quincuntial/article/details/89670199
https://www.zhihu.com/question/60321866
view相當於numpy中resize()的功能,但是用法可能不太一樣.可以參考:https://blog.csdn.net/york1996/article/details/81949843
view只能用在contiguous的variable上。如果在view之前用了transpose,permute等,需要用contiguous()來返回一個contiguous copy 可參考:https://blog.csdn.net/appleml/article/details/80143212?utm_source=blogxgwz0
但是在pytorch最新版本0.4版本中,增加了torch.reshape(),這個與numpy.reshape 的功能類似。它大致相當於tensor.contiguous().view()
permute是維度換位,是更靈活的transpose,可以靈活的對原數據的維度進行調換,而數據本身不變(transpose也是)。
可以參考:https://blog.csdn.net/york1996/article/details/81876886