MCPcopy Create free account
hub / github.com/PyGCL/PyGCL / main

Function main

examples/BGRL_L2L.py:123–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121
122
123def main():
124 device = torch.device('cuda')
125 path = osp.join(osp.expanduser('~'), 'datasets', 'WikiCS')
126 dataset = WikiCS(path, transform=T.NormalizeFeatures())
127 data = dataset[0].to(device)
128
129 aug1 = A.Compose([A.EdgeRemoving(pe=0.5), A.FeatureMasking(pf=0.1)])
130 aug2 = A.Compose([A.EdgeRemoving(pe=0.5), A.FeatureMasking(pf=0.1)])
131
132 gconv = GConv(input_dim=dataset.num_features, hidden_dim=256, num_layers=2).to(device)
133 encoder_model = Encoder(encoder=gconv, augmentor=(aug1, aug2), hidden_dim=256).to(device)
134 contrast_model = BootstrapContrast(loss=L.BootstrapLatent(), mode='L2L').to(device)
135
136 optimizer = Adam(encoder_model.parameters(), lr=0.01)
137
138 with tqdm(total=100, desc='(T)') as pbar:
139 for epoch in range(1, 101):
140 loss = train(encoder_model, contrast_model, data, optimizer)
141 pbar.set_postfix({'loss': loss})
142 pbar.update()
143
144 test_result = test(encoder_model, data)
145 print(f'(E): Best test F1Mi={test_result["micro_f1"]:.4f}, F1Ma={test_result["macro_f1"]:.4f}')
146
147
148if __name__ == '__main__':

Callers 1

BGRL_L2L.pyFile · 0.70

Calls 5

BootstrapContrastClass · 0.90
GConvClass · 0.70
EncoderClass · 0.70
trainFunction · 0.70
testFunction · 0.70

Tested by

no test coverage detected