Thank you very much, albanD! It worked! 
In case anyone comes across this post in the future, this is how albanD’s solution ended up looking as for me:
{
   torch::NoGradGuard no_grad;
   affine2->bias[0] = 0.5;
   affine2->bias[1] = 1.0;
   affine2->bias[2] = 0.5;
}