Hi @afshin67 , I used the function “clamp” to clip gradients, but I don’t know if it was correct:
for(int i=0; i<net.parameters().size(); i++)
{
net.parameters().at(i).grad() = torch::clamp(net.parameters().at(i).grad(), -GRADIENT_CLIP, GRADIENT_CLIP);			
}
optimizer.step();
Is there something that I ignored? And what could I do?
Best,
June