Solved by KFrank in post #4 
              
              
                Hello Clement! 

Please feel free to post a short, complete, runnable script 
that has the original code you posted (that fails when the 
tensor values become to large), together with your improved 
attempt (using logsumexp() or whatever).  If you show us 
what fails or what the discrepancy is, some…