Solved by Amos_Brazzoli in post #5 
              
              
                Thanks K. Frank, 
I managed to find a wordaround using nn.Softmax(dim=2) instead of my own function. 
They yield similar enough results