Closed jiqing-feng closed 2 months ago
I found this problem came from numpy, in python3.8, numpy will cast int to float:
So I suggest that we can use p_mask.numpy()
instead of np.array(p_mask)
Hi @amyeroberts , could you take a look at this PR? I am waiting for your response, thx!
Hey @jiqing-feng! I'm trying to reproduce the issue but failing at doing so with python 3.8.18 and numpy 1.24.4.
>>> import torch
>>> import numpy as np
>>> a = torch.tensor([1,2,3], dtype=torch.int64)
>>> a
tensor([1, 2, 3])
>>> np.array(a)
array([1, 2, 3])
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=8, micro=18, releaselevel='final', serial=0)
What's your torch version?
Hey @jiqing-feng! I'm trying to reproduce the issue but failing at doing so with python 3.8.18 and numpy 1.24.4.
>>> import torch >>> import numpy as np >>> a = torch.tensor([1,2,3], dtype=torch.int64) >>> a tensor([1, 2, 3]) >>> np.array(a) array([1, 2, 3]) >>> import sys >>> sys.version_info sys.version_info(major=3, minor=8, micro=18, releaselevel='final', serial=0)
What's your torch version?
torch 2.3.0+cpu
Hey @jiqing-feng! I'm trying to reproduce the issue but failing at doing so with python 3.8.18 and numpy 1.24.4.
>>> import torch >>> import numpy as np >>> a = torch.tensor([1,2,3], dtype=torch.int64) >>> a tensor([1, 2, 3]) >>> np.array(a) array([1, 2, 3]) >>> import sys >>> sys.version_info sys.version_info(major=3, minor=8, micro=18, releaselevel='final', serial=0)
What's your torch version?
torch 2.3.0+cpu
I just checked that torch 2.3.1+cpu fixed this issue; you can close this PR if you think there is no need to do this change. BTW, I suppose the change will not break anything, and it's more common. Thx!
@jiqing-feng Thanks for investigating across the different pytorch versions. If the fix it only in later versions, then this is a change we'd still want as we officially support torch >= 1.11
Hi @Narsil @amyeroberts
This PR fixed the error for question-answering pipeline, the error could be reproduced by
Traceback: