view size not compatible.. error in Google Colab

30 views Asked by At

I am working with Pytorch on google colab and there is this very strange error.

     65 
     66         # flatten
---> 67         x = x.reshape(x.size(0), -1)
     68 
     69         x = self.dropout5(F.elu(self.bn5(self.fc1(x))))

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.

I have changed view to reshape but the error still persists. I have tried using contiguous().view (as many forums have suggested) as well but it doesn't work.

I call it strange because it has worked before but now suddenly it does not. I am almost certain that this is a google colab exclusive error. I have tried debugging using pdb trace but to no avail.

Any way to fix this?

0

There are 0 answers