Getting the "some of the strides of a numpy error are negative" on using Facebook Infersent model

Hi,

You should use torch.from_numpy() to convert numpy arrays to Tensor before giving them to pytorch’s function to improve performances.

The error you see most certainly comes from the fact that not all numpy arrays can be represented as Tensor (arrays that were flipped in particular). You can use np.ascontiguousarray() before giving your array to pytorch to make sure it will work.

5 Likes