Solved by IliasPap in post #2 
              
              
                model = train_model(model, criterion, optimizer, exp_lr_scheduler, num_epochs=num_epochs)

What does function train_model return ? Are you sure it returns the model ? Because your code seems right.