Bool tensor does not support the `-` operator
See original GitHub issue🐛 Bug
Hi, this tool is very powerful and amazing. Thanks a lot!
However, when I ran gcn.py from example for testing, an error occurred:
Traceback (most recent call last): File “gcn.py”, line 55, in <module> train() File “gcn.py”, line 39, in train F.nll_loss(model()[data.train_mask], data.y[data.train_mask]).backward() File “/Users/william/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in call result = self.forward(*input, **kwargs) File “gcn.py”, line 25, in forward x = F.relu(self.conv1(x, edge_index)) File “/Users/william/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in call result = self.forward(*input, **kwargs) File “/Users/william/anaconda3/lib/python3.6/site-packages/torch_geometric/nn/conv/gcn_conv.py”, line 100, in forward self.improved, x.dtype) File “/Users/william/anaconda3/lib/python3.6/site-packages/torch_geometric/nn/conv/gcn_conv.py”, line 78, in norm edge_index, edge_weight, fill_value, num_nodes) File “/Users/william/anaconda3/lib/python3.6/site-packages/torch_geometric/utils/loop.py”, line 107, in add_remaining_self_loops inv_mask = 1 - mask File “/Users/william/anaconda3/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~
orbitwise_not()
operator instead.
It seems that bool tensor does not support the -
operator yet. So I modified the line 107 in loop.py as:
inv_mask = ~mask # inv_mask = 1 - mask
and then re-run gcn.py. The result shows that it works!
… Epoch: 200, Train: 1.0000, Val: 0.8080, Test: 0.8240
Environment
- OS: macOS 10.14.6
- Python version: 3.6
- PyTorch version: 1.2.0
- CUDA/cuDNN version: 10.1
- GCC version: clang
- Any other relevant information:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (7 by maintainers)
Top GitHub Comments
This is a bug introduced by PyTorch 1.2. You can install PyTorch Geometric from master to fix this (just clone the repository and run
python setup.py install
). I will craft a new release soon to fix this.Please update
torch-cluster
to version 1.4.4. The SignedGCN bug should be fixed in PyG master by now.