python运行报错:
RuntimeError: view size is not compatible with input tensor’s size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(…) instead.
感谢 柠檬树下你和我 的文章,知道了报错原因和解决方案。
报错原因: view()需要Tensor中的元素地址是连续的,实际操作时可能出现Tensor不连续的情况。
解决方案: 在出错代码提示行的.view前加.contiguous(),使其变为连续的即可,如下图所示。
3 感谢链接https://blog.csdn.net/m0_52347246/article/details/120176728



