-
Notifications
You must be signed in to change notification settings - Fork 83
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
Check hypergraphs #256
Check hypergraphs #256
Changes from 23 commits
c2e4132
97c62e4
fefc88b
04953be
62b7c5a
1b7b01d
80ed75f
3d5c6b7
76f0bdb
937ca45
02c731d
c1d54f9
a89d1f1
31d297c
712cd85
c941ee5
73df4e3
9426857
02e16f7
2e8c285
b0c36f5
c0c0e5d
cfbde34
985934a
5b8a423
c95265f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,13 @@ def UniGIN_layer(self): | |
self.in_channels = 10 | ||
return UniGINLayer(in_channels=self.in_channels) | ||
|
||
def test_forward(self, UniGIN_layer): | ||
@pytest.fixture | ||
def UniGIN_layer2(self): | ||
"""Return a UniGIN layer.""" | ||
self.in_channels = 10 | ||
return UniGINLayer(in_channels=self.in_channels, use_norm=True) | ||
|
||
def test_forward(self, UniGIN_layer, UniGIN_layer2): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No mix of under_scores and CamelCase. |
||
"""Test the forward pass of the UniGIN layer.""" | ||
n_nodes, n_edges = 2, 3 | ||
incidence = torch.from_numpy(np.random.rand(n_nodes, n_edges)).to_sparse() | ||
|
@@ -25,3 +31,8 @@ def test_forward(self, UniGIN_layer): | |
|
||
assert x_0.shape == torch.Size([n_nodes, self.in_channels]) | ||
assert x_1.shape == torch.Size([n_edges, self.in_channels]) | ||
|
||
x_0, x_1 = UniGIN_layer2.forward(x_0, incidence) | ||
|
||
assert x_0.shape == torch.Size([n_nodes, self.in_channels]) | ||
assert x_1.shape == torch.Size([n_edges, self.in_channels]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ class HyperGAT(torch.nn.Module): | |
Dimension of the hidden features. | ||
n_layers : int, default = 2 | ||
Amount of message passing layers. | ||
layer_drop: float, default = 0.2 | ||
Dropout rate for the hidden features. | ||
|
||
References | ||
---------- | ||
|
@@ -29,6 +31,7 @@ def __init__( | |
in_channels, | ||
hidden_channels, | ||
n_layers=2, | ||
layer_drop=0.2, | ||
): | ||
super().__init__() | ||
layers = [] | ||
|
@@ -42,6 +45,7 @@ def __init__( | |
) | ||
) | ||
self.layers = torch.nn.ModuleList(layers) | ||
self.layer_drop = torch.nn.Dropout(layer_drop) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
def forward(self, x_0, incidence_1): | ||
"""Forward computation through layers, then linear layer, then global max pooling. | ||
|
@@ -62,5 +66,6 @@ def forward(self, x_0, incidence_1): | |
""" | ||
for layer in self.layers: | ||
x_0, x_1 = layer.forward(x_0, incidence_1) | ||
x_0 = self.layer_drop(x_0) | ||
|
||
return x_0, x_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid mix of under_scores and CamelCase in names.
Python guidelines ask for all lower cases and under_scores in function names, see Pep8. Can you adapt the naming of this function and the others which may have the same problem? Thanks.