You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dhg/models/graphs/bgnn.py
+76-35Lines changed: 76 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -10,48 +10,89 @@ class BGNN_Adv(nn.Module):
10
10
r"""The BGNN-Adv model proposed in `Cascade-BGNN: Toward Efficient Self-supervised Representation Learning on Large-scale Bipartite Graphs <https://arxiv.org/pdf/1906.11994.pdf>`_ paper (TNNLS 2020).
11
11
12
12
Args:
13
-
``num_users`` (``int``): The Number of users.
14
-
``num_items`` (``int``): The Number of items.
15
-
``emb_dim`` (``int``): Embedding dimension.
16
-
``num_layers`` (``int``): The Number of layers. Defaults to ``3``.
17
-
``drop_rate`` (``float``): Dropout rate. Randomly dropout the connections in training stage with probability ``drop_rate``. Default: ``0.0``.
13
+
``u_dim`` (``int``): The dimension of the vertex feature in set :math:`U`.
14
+
``v_dim`` (``int``): The dimension of the vertex feature in set :math:`V`.
``X_u`` (``torch.Tensor``): The feature matrix of vertices in set :math:`U`.
35
+
``X_v`` (``torch.Tensor``): The feature matrix of vertices in set :math:`V`.
36
+
``g`` (``BiGraph``): The bipartite graph.
34
37
"""
35
-
nn.init.normal_(self.u_embedding.weight, 0, 0.1)
36
-
nn.init.normal_(self.i_embedding.weight, 0, 0.1)
38
+
last_X_u, last_X_v=X_u, X_v
39
+
for_idxinrange(self.layer_depth):
40
+
if_idx%2==0:
41
+
_tmp=self.layers[_idx](last_X_v)
42
+
last_X_u=g.v2u(_tmp, aggr="sum")
43
+
else:
44
+
_tmp=self.layers[_idx](last_X_u)
45
+
last_X_v=g.u2v(_tmp, aggr="sum")
46
+
returnlast_X_u
47
+
48
+
deftrain_with_cascaded(self):
49
+
pass
50
+
51
+
deftrain_with_end2end(self):
52
+
pass
53
+
54
+
55
+
classBGNN_MLP(nn.Module):
56
+
r"""The BGNN-MLP model proposed in `Cascade-BGNN: Toward Efficient Self-supervised Representation Learning on Large-scale Bipartite Graphs <https://arxiv.org/pdf/1906.11994.pdf>`_ paper (TNNLS 2020).
0 commit comments