I am training yolov3 on my data using this code here : https://github.com/cfotache/pytorch_custom_yolo_training/
But I am getting this annoying deprecation warnings
Warning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead. (expandTensors at /pytorch/aten/src/ATen/native/IndexingUtils.h:20)
I tried using python3 -W ignore train.py
I tried adding :
import warnings
warnings.filterwarnings('ignore')
but the warning is still persistent.
I found this piece of code on here on stackoverflow that prints that stack on warnings ,
import traceback
import warnings
import sys
def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
log = file if hasattr(file,'write') else sys.stderr
traceback.print_stack(file=log)
log.write(warnings.formatwarning(message, category, filename, lineno, line))
warnings.showwarning = warn_with_traceback
and here's what I get :
File "/content/pytorch_custom_yolo_training/train.py", line 102, in <module>
loss = model(imgs, targets)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/content/pytorch_custom_yolo_training/models.py", line 267, in forward
x, *losses = module[0](x, targets)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/content/pytorch_custom_yolo_training/models.py", line 203, in forward
loss_x = self.mse_loss(x[mask], tx[mask])
File "/usr/lib/python3.6/warnings.py", line 99, in _showwarnmsg
msg.file, msg.line)
File "/content/pytorch_custom_yolo_training/train.py", line 29, in warn_with_traceback
traceback.print_stack(file=log)
/pytorch/aten/src/ATen/native/IndexingUtils.h:20: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.
Going to the files and functions mentioned in the stack , I don't find any uint8
.
What can I to solve the problem or even stop getting these warnings ?
Found the problem.
line : loss_x = self.mse_loss(x[mask], tx[mask])
the mask
variable was a ByteTensor
which is deprecated . Just replaced it with a BoolTensor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With