大家好

最近在學習pytorch應用實作
要使用很多國外高手寫的套件來實作
但是這類套件很吃pytorch版本
所以只能自己 debug
但是偶而還是有 warning 跑出來

例如:

pytorch\aten\src\ATen/native/IndexingUtils.h:20: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.

找一找還真有取消方式

參考:
https://github.com/open-mmlab/mmdetection/issues/2017

用以下方式就可以

import warnings
warnings.filterwarnings("ignore", category=UserWarning)

給大家參考囉
感恩