Solved by KFrank in post #2 
              
              
                Hi Tony! 

Just use pytorch to minimize the negative of your scalar. 
That is: 
my_single_scalar = model (input)
my_negative_scalar = -my_single_scalar
optim.zero_grads()
my_negative_scalar.backwards()
optim.step()

(Pytorch optimizers minimize their objective functions.  To maximize, 
you just flip…