Scatter_max overflows with int
See original GitHub issue🐛 Bug
I have a torch_geometric.data.Data object with the x attribute in torch.int format. (the attribute represents vertex colours, hence the type).
If I attempt to use torch.nn.max_pool, it will yield an error in scatter_max. Note that using torch.nn.avg_pool gives the desired result, as does converting the x attribute to float before trying scatter_max (which is what I resorted to doing)
>>> avg_pool(clusters,data)
Batch(edge_index=[2, 64384], pos=[10758, 3], x=[10758, 3])
>>> max_pool(clusters,data)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/wp01/trainees/aykroydc/tools/miniconda3/lib/python3.7/site-packages/torch_geometric/nn/pool/max_pool.py", line 64, in max_pool
x = _max_pool_x(cluster, data.x)
File "/home/wp01/trainees/aykroydc/tools/miniconda3/lib/python3.7/site-packages/torch_geometric/nn/pool/max_pool.py", line 9, in _max_pool_x
return scatter_('max', x, cluster, dim_size=size)
File "/home/wp01/trainees/aykroydc/tools/miniconda3/lib/python3.7/site-packages/torch_geometric/utils/scatter.py", line 28, in scatter_
out = op(src, index, 0, None, dim_size, fill_value)
File "/home/wp01/trainees/aykroydc/tools/miniconda3/lib/python3.7/site-packages/torch_scatter/max.py", line 98, in scatter_max
src, out, index, dim = gen(src, index, dim, out, dim_size, fill_value)
File "/home/wp01/trainees/aykroydc/tools/miniconda3/lib/python3.7/site-packages/torch_scatter/utils/gen.py", line 18, in gen
out = src.new_full(out_size, fill_value)
RuntimeError: value cannot be converted to type int without overflow: -1e+38
Nothing particular about the data I’m using:
>>> data.x.dtype
torch.int32
>>> data.x.shape
torch.Size([53490, 3])
>>> data.x.max()
tensor(239, dtype=torch.int32)
>>> data.x.min()
tensor(14, dtype=torch.int32)
>>> clusters.shape
torch.Size([53490])
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Scatter_max overflows with int · Issue #327
I have a torch_geometric.data.Data object with the x attribute in torch.int format. (the attribute represents vertex colours, hence the type).
Read more >Scatter Max — pytorch_scatter 1.3.0 documentation
Maximizes all values from the src tensor into out at the indices specified in the index tensor along a given axis dim .If...
Read more >tf.compat.v1.scatter_max | TensorFlow v2.11.0
Reduces sparse updates into a variable reference using the max operation.
Read more >Implement scatter max with numpy or pytorch for two ...
I want to implement a vectorized version of the following function using numpy or pytorch: def scatter_max_2(src, index, out): src_shape ...
Read more >Check for Integer Overflow
Write a “C” function, int addOvf(int* result, int a, int b) If there is no overflow, the function places the resultant = sum...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, this is possible too. I was making use of broadcasting though.
Hi, are you sure you are running the latest PyG version? This error was fixed a while ago. The default fill value is now
-1e9
(see here).