Another way to state my question, in a code example which I hope is fairly general, as I couldn’t seem to find general examples on the PyTorch docs or on here.
Is this the correct idea of a way of training and testing for several epochs in PyTorch?
for epoch in range(no_epochs):
    
    running_loss = 0
    
    for image,target in training_set:        
        
        unet, loss = defnet.train( unet, image, target)
        
        running_loss += loss
    
    training_loss[epoch] = running_loss / len(training_set)
    

    running_test_loss =0
    with torch.no_grad():
        criterion = nn.CrossEntropyLoss()
        evaluation_unet = unet.eval()
        for image, target in test_set:

            running_test_loss += criterion(  evaluation_unet(image),  target)
        
        loss_validation[epoch] = cel / len(test_set)


My concern is that I don’t want my model to “go on training” on the test set. Is “torch.no_grad” and “model.eval()” enough to make sure this does not happen?