view size is not compatible with input tensor’s size and stride 如题。在对pytorch tensor使用view()方法时报错。 原因:对tensor使用view()时要求tensor在内存中地址是连续的,但有时不满足这个条件。 解决方法:将地址变为连续的。在.view()前加上.contiguous()。 如下: a = torch.tensor([[1,1,4], [5, 1<