MCPcopy Index your code
hub / github.com/PyGCL/PyGCL / Encoder

Class Encoder

examples/GRACE.py:33–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32
33class Encoder(torch.nn.Module):
34 def __init__(self, encoder, augmentor, hidden_dim, proj_dim):
35 super(Encoder, self).__init__()
36 self.encoder = encoder
37 self.augmentor = augmentor
38
39 self.fc1 = torch.nn.Linear(hidden_dim, proj_dim)
40 self.fc2 = torch.nn.Linear(proj_dim, hidden_dim)
41
42 def forward(self, x, edge_index, edge_weight=None):
43 aug1, aug2 = self.augmentor
44 x1, edge_index1, edge_weight1 = aug1(x, edge_index, edge_weight)
45 x2, edge_index2, edge_weight2 = aug2(x, edge_index, edge_weight)
46 z = self.encoder(x, edge_index, edge_weight)
47 z1 = self.encoder(x1, edge_index1, edge_weight1)
48 z2 = self.encoder(x2, edge_index2, edge_weight2)
49 return z, z1, z2
50
51 def project(self, z: torch.Tensor) -> torch.Tensor:
52 z = F.elu(self.fc1(z))
53 return self.fc2(z)
54
55
56def train(encoder_model, contrast_model, data, optimizer):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected