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

相关文章:

  • 2021-12-03
  • 2022-02-06
  • 2022-01-02
  • 2021-05-21
  • 2021-06-11
  • 2021-12-08
  • 2021-11-02
  • 2021-05-16
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2022-01-21
  • 2021-11-23
  • 2022-01-19
  • 2022-12-23
  • 2021-07-30
相关资源
相似解决方案