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.
Thanks for the reply @albanD. I tried your suggestions but I am unable to convert a list of strings to a tensor.
So, I converted the list to a one-hot encoded list and then convert it to a contiguous array. However, the function encode defined in Infersent is taking only a list of strings. I get this error now:
Tensors cannot contain strings. You would usually use an Embedding layer ton convert a string to some learnable features that represent that string. And then use these features in your model.