facebookresearch / ClassyVision

An end-to-end PyTorch framework for image and video classification
https://classyvision.ai
MIT License
1.59k stars 278 forks source link

Silence mixup warnings #770

Closed edpizzi closed 2 years ago

edpizzi commented 2 years ago

Summary: Use Tensor.to(...) to move a tensor to the desired device and dtype instead of using torch.tensor(...). The current approach generates warnings like the following:

.../classy_vision/dataset/transforms/mixup.py:266: 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).
  return torch.tensor(lam_batch, device=x.device, dtype=x.dtype).unsqueeze(1)

Differential Revision: D31070769

facebook-github-bot commented 2 years ago

This pull request was exported from Phabricator. Differential Revision: D31070769

facebook-github-bot commented 2 years ago

This pull request was exported from Phabricator. Differential Revision: D31070769

facebook-github-bot commented 2 years ago

This pull request was exported from Phabricator. Differential Revision: D31070769

facebook-github-bot commented 2 years ago

This pull request has been merged in facebookresearch/ClassyVision@659d7f788c941a8c0d08dd74e198b66bd8afa7f5.