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

Function main

examples/DGI_transductive.py:72–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70
71
72def main():
73 device = torch.device('cuda')
74 path = osp.join(osp.expanduser('~'), 'datasets')
75 dataset = Planetoid(path, name='Cora', transform=T.NormalizeFeatures())
76 data = dataset[0].to(device)
77
78 gconv = GConv(input_dim=dataset.num_features, hidden_dim=512, num_layers=2).to(device)
79 encoder_model = Encoder(encoder=gconv, hidden_dim=512).to(device)
80 contrast_model = SingleBranchContrast(loss=L.JSD(), mode='G2L').to(device)
81
82 optimizer = Adam(encoder_model.parameters(), lr=0.01)
83
84 with tqdm(total=300, desc='(T)') as pbar:
85 for epoch in range(1, 301):
86 loss = train(encoder_model, contrast_model, data, optimizer)
87 pbar.set_postfix({'loss': loss})
88 pbar.update()
89
90 test_result = test(encoder_model, data)
91 print(f'(E): Best test F1Mi={test_result["micro_f1"]:.4f}, F1Ma={test_result["macro_f1"]:.4f}')
92
93
94if __name__ == '__main__':

Callers 1

Calls 5

GConvClass · 0.70
EncoderClass · 0.70
trainFunction · 0.70
testFunction · 0.70

Tested by

no test coverage detected