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

[Code Coverage] models/RECT_L #6623

Merged
merged 5 commits into from
Feb 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add test for RECT model
  • Loading branch information
Karuna Bhaila committed Feb 7, 2023
commit 52128d45f75e304d75c0e6b07c7bea4ab036be2d
30 changes: 30 additions & 0 deletions test/nn/models/test_rect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
import torch

from torch_geometric.nn.models import RECT_L

dropouts = [0.0, 0.5]


@pytest.mark.parametrize('dropout', dropouts)
def test_rect(dropout):
x = torch.randn(6, 8)
y = torch.tensor([1, 0, 0, 2, 1, 1])
edge_index = torch.tensor([[0, 1, 1, 2, 4, 5], [1, 0, 2, 1, 5, 4]])
mask = torch.randint(0, 2, (6,), dtype=torch.bool)

model = RECT_L(8, 16, dropout=dropout)
assert str(model) == 'RECT_L(8, 16)'

out = model(x, edge_index)
assert out.size() == (6, 8)

# Test embed
out = model.embed(x, edge_index)
assert out.size() == (6, 16)
assert torch.allclose(model.embed(x, edge_index), out)

# Test get_semantic_labels
out = model.get_semantic_labels(x, y, mask)
assert out.size() == (mask.sum(), 8)
assert torch.allclose(model.get_semantic_labels(x, y, mask), out)