Pytorch:module 'torch' has no attribute 'bool'
這個應該是有些版本的Pytorch會遇到這個問題,我用0.4.0版本測試發現torch.bool是有的,但是1.0.0確實沒有了,我看了一篇文章:
來源:http://www.sohu.com/a/332756215_473283
Pytorch 1.2.0 來了!
比較操作返回的數據類型由 torch.uint8 變為 torch.bool
1>>> torch.tensor([1, 2, 3]) < torch.tensor([3, 1, 2])
2tensor([1, 0, 0], dtype=torch.uint8)
所以應該猜測是1.2.0之前的版本會有這個問題。
解決辦法就是把torch.bool換成torch.uint8