Text: Copy Construct warning

Created on 2 Nov 2018  路  5Comments  路  Source: pytorch/text

Hello,
was this ever fixed ?

/usr/local/lib/python3.5/dist-packages/torchtext/data/field.py:308: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).

Most helpful comment

for future reference: https://github.com/pytorch/pytorch/issues/16627. In summary, try to replace torch.tensor with torch.as_tensor

All 5 comments

also what if you need to convert tensor to dtype=torch.float ?
replacing with clone().detach() is not going to convert the tensor....

Could you provide the case where you get this error?

I assume that arr is a torch.tensor, which means that the numericalization / postprocessing casts it into that at some point (as the standard pipeline shouldn't do that prior to L359).

@toli-belo feel free to reopen the issue if you still have questions.

for future reference: https://github.com/pytorch/pytorch/issues/16627. In summary, try to replace torch.tensor with torch.as_tensor

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NoaKel picture NoaKel  路  6Comments

aatkinson picture aatkinson  路  3Comments

dilettacal picture dilettacal  路  6Comments

david-waterworth picture david-waterworth  路  4Comments

vince62s picture vince62s  路  3Comments