TimDettmers/sparse_learning

AttributeError: 'Tensor' object has no attribute 'bool'

colorjam opened this issue · 2 comments

Hi! Thank for your awesome work. I run python main.py --data cifar10 --model wrn-28-2 but got the following error:

Traceback (most recent call last):
  File "mnist_cifar/main.py", line 304, in <module>
    main()
  File "mnist_cifar/main.py", line 296, in main
    mask.at_end_of_epoch()
  File "/userhome/repo/SparseLearning/sparselearning/core.py", line 269, in at_end_of_epoch
    self.truncate_weights()
  File "/userhome/repo/SparseLearning/sparselearning/core.py", line 371, in truncate_weights
    self.gather_statistics()
  File "/userhome/repo/SparseLearning/sparselearning/core.py", line 433, in gather_statistics
    self.name2variance[name] = self.redistribution_func(self, name, weight, mask)
  File "/userhome/repo/SparseLearning/sparselearning/funcs.py", line 37, in momentum_redistribution
    print(mask)
AttributeError: 'Tensor' object has no attribute 'bool'

I think the error is caused by using PyTorch < 1.3. If you install PyTorch 1.3 the tensor should have the bool object. Do you run a version of PyTorch earlier than 1.3?

Yes, after I upgrade PyTorch, it works.