thanks for your reply @god_sp33d
but I got this for the first solution
ValueError: optimizing a parameter that doesn't require gradients
but for the second solution
initially I set my requires_grad is set to False and the model did not train but when I set it to True and run it the batch loss I get it so high 24.034479
my code is
for param in model_transfer.parameters(): param.requires_grad = True criterion_transfer = nn.CrossEntropyLoss() optimizer_transfer=optim.SGD(filter(lambdap:p.requires_grad,model_transfer.parameters()),lr=0.001)