Should the parameters of a neural network be reset in each run?

Viewed 202

I am training a Graph Convolutional Network (GCN). My training code is as follows (the complete code is long so I put just the corresponding snippet):

for i in range(1, runs + 1):

        data = data.to(device)

        model.to(device).reset_parameters()
        
        optimizer = Adam(model.parameters(), lr=0.001, weight_decay=5e-4)
        if torch.cuda.is_available():
            torch.cuda.synchronize()
        t_start = time.perf_counter()
        best_val_loss = float('inf')
        test_acc = 0
        
        for epoch in range(1, epochs + 1):
            
            train(model, optimizer, data)
            eval_info = evaluate(model, data)

            if eval_info['val_loss'] < best_val_loss:
                best_val_loss = eval_info['val_loss']
                test_acc = eval_info['test_acc']

        if torch.cuda.is_available():
            torch.cuda.synchronize()
        t_end = time.perf_counter()
        

My question is about resetting the parameters. If use model.to(device) instead of model.to(device).reset_parameters(), the mean accuracy of all runs (e.g. 10 runs) is around 5% higher than when I keep model.to(device).reset_parameters(). The validation losses of the two cases are nearly the same. I wonder whether I should reset the parameter in each run or not?

0 Answers
Related