Solved by KFrank in post #3 
              
              
                Hi Wouter! 

To answer this specific question, yes, you can add a loss term 
that will push your predictions onto the unit sphere. 
When the (L2) norm or your prediction is 1, the prediction is on 
the unit sphere.  So just add unit-sphere mismatch term: 
sphere_loss = fac * ((preds**2).sum (dim = 1…