TimDettmers / sparse_learning

Sparse learning library and sparse momentum resources.
MIT License
377 stars 45 forks source link

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

Closed colorjam closed 4 years ago

colorjam commented 4 years ago

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'
TimDettmers commented 4 years ago

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?

colorjam commented 4 years ago

Yes, after I upgrade PyTorch, it works.