Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-scatter
Commits
50e4214b
Commit
50e4214b
authored
Apr 13, 2019
by
Matthias Fey
Committed by
GitHub
Apr 13, 2019
Browse files
Merge pull request #40 from jhultman/minmax_tuple
min and max should still return arg when index empty
parents
5e69a349
8a8d068c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
torch_scatter/max.py
torch_scatter/max.py
+1
-1
torch_scatter/min.py
torch_scatter/min.py
+5
-5
No files found.
torch_scatter/max.py
View file @
50e4214b
...
...
@@ -97,5 +97,5 @@ def scatter_max(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
"""
src
,
out
,
index
,
dim
=
gen
(
src
,
index
,
dim
,
out
,
dim_size
,
fill_value
)
if
src
.
size
(
dim
)
==
0
:
# pragma: no cover
return
out
return
out
,
index
.
new_full
(
out
.
size
(),
-
1
)
return
ScatterMax
.
apply
(
out
,
src
,
index
,
dim
)
torch_scatter/min.py
View file @
50e4214b
...
...
@@ -44,9 +44,9 @@ def scatter_min(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
Minimizes all values from the :attr:`src` tensor into :attr:`out` at the
indices specified in the :attr:`index` tensor along a given axis
:attr:`dim`.If multiple indices reference the same location, their
**contributions m
ax
imize** (`cf.` :meth:`~torch_scatter.scatter_add`).
**contributions m
in
imize** (`cf.` :meth:`~torch_scatter.scatter_add`).
The second return tensor contains index location in :attr:`src` of each
minimum value (known as argm
ax
).
minimum value (known as argm
in
).
For one-dimensional tensors, the operation computes
...
...
@@ -83,10 +83,10 @@ def scatter_min(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
index = torch.tensor([[ 4, 5, 4, 2, 3], [0, 0, 2, 2, 1]])
out = src.new_zeros((2, 6))
out, argm
ax
= scatter_min(src, index, out=out)
out, argm
in
= scatter_min(src, index, out=out)
print(out)
print(argm
ax
)
print(argm
in
)
.. testoutput::
...
...
@@ -97,5 +97,5 @@ def scatter_min(src, index, dim=-1, out=None, dim_size=None, fill_value=0):
"""
src
,
out
,
index
,
dim
=
gen
(
src
,
index
,
dim
,
out
,
dim_size
,
fill_value
)
if
src
.
size
(
dim
)
==
0
:
# pragma: no cover
return
out
return
out
,
index
.
new_full
(
out
.
size
(),
-
1
)
return
ScatterMin
.
apply
(
out
,
src
,
index
,
dim
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment