Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtraction, the - operator, with a bool tensor is not supported. #73

Open
daiwei12 opened this issue Sep 25, 2019 · 2 comments
Open

Subtraction, the - operator, with a bool tensor is not supported. #73

daiwei12 opened this issue Sep 25, 2019 · 2 comments

Comments

@daiwei12
Copy link

pytorch-pretrained-bert 0.6.2
pytorch-transformers 1.1.0
torch 1.2.0

Traceback (most recent call last):
  File "/home/david/workspace/BERTSum/src/train.py", line 71, in run
    train(args, device_id)
  File "/home/david/workspace/BERTSum/src/train.py", line 264, in train
    trainer.train(train_iter_fct, args.train_steps)
  File "/home/david/workspace/BERTSum/src/models/trainer.py", line 142, in train
    for i, batch in enumerate(train_iter):
  File "/home/david/workspace/BERTSum/src/models/data_loader.py", line 131, in __iter__
    for batch in self.cur_iter:
  File "/home/david/workspace/BERTSum/src/models/data_loader.py", line 235, in __iter__
    batch = Batch(minibatch, self.device, self.is_test)
  File "/home/david/workspace/BERTSum/src/models/data_loader.py", line 31, in __init__
    mask = 1 - (src == 0)
  File "/home/david/software/anaconda3/envs/bert_sum/lib/python3.6/site-packages/torch/tensor.py", line 325, in __rsub__
    return _C._VariableFunctions.rsub(self, other)
RuntimeError: Subtraction, the `-` operator, with a bool tensor is not supported. If you are trying to invert a mask, use the `~` or `bitwise_not()` operator instead.
@astariul
Copy link

It comes from your PyTorch version.

nlpyang/PreSumm#2

Downgrade to 1.1.0

@Santosh-Gupta
Copy link

Santosh-Gupta commented Sep 30, 2019

If you would like to fork your own version, there's three lines where you have to change '1-' to '~'

I made these changes to my own fork

https://github.com/Santosh-Gupta/BertSum/blob/master/src/models/encoder.py

https://github.com/Santosh-Gupta/BertSum/blob/master/src/models/data_loader.py

More details here

https://github.com/pytorch/pytorch/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants