forked from pyg-team/pytorch_geometric
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Type Hints]
nn.GraphSizeNorm
(pyg-team#5729)
Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
- Loading branch information
1 parent
f7fc23e
commit cd69f57
Showing
3 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import torch | ||
|
||
from torch_geometric.nn import GraphSizeNorm | ||
from torch_geometric.testing import is_full_test | ||
|
||
|
||
def test_graph_size_norm(): | ||
x = torch.randn(100, 16) | ||
batch = torch.repeat_interleave(torch.full((10, ), 10, dtype=torch.long)) | ||
|
||
norm = GraphSizeNorm() | ||
out = norm(torch.randn(100, 16), batch) | ||
assert str(norm) == 'GraphSizeNorm()' | ||
|
||
out = norm(x, batch) | ||
assert out.size() == (100, 16) | ||
|
||
if is_full_test(): | ||
jit = torch.jit.script(norm) | ||
assert torch.allclose(jit(x, batch), out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters