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

Function main

examples/InfoGraph.py:118–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116
117
118def main():
119 device = torch.device('cuda')
120 path = osp.join(osp.expanduser('~'), 'datasets')
121 dataset = TUDataset(path, name='PTC_MR')
122 dataloader = DataLoader(dataset, batch_size=128)
123 input_dim = max(dataset.num_features, 1)
124
125 gconv = GConv(input_dim=input_dim, hidden_dim=32, activation=torch.nn.ReLU, num_layers=2).to(device)
126 fc1 = FC(hidden_dim=32 * 2)
127 fc2 = FC(hidden_dim=32 * 2)
128 encoder_model = Encoder(encoder=gconv, local_fc=fc1, global_fc=fc2).to(device)
129 contrast_model = SingleBranchContrast(loss=L.JSD(), mode='G2L').to(device)
130
131 optimizer = Adam(encoder_model.parameters(), lr=0.01)
132
133 with tqdm(total=100, desc='(T)') as pbar:
134 for epoch in range(1, 101):
135 loss = train(encoder_model, contrast_model, dataloader, optimizer)
136 pbar.set_postfix({'loss': loss})
137 pbar.update()
138
139 test_result = test(encoder_model, dataloader)
140 print(f'(E): Best test F1Mi={test_result["micro_f1"]:.4f}, F1Ma={test_result["macro_f1"]:.4f}')
141
142
143if __name__ == '__main__':

Callers 1

InfoGraph.pyFile · 0.70

Calls 6

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

Tested by

no test coverage detected