You’ve probably come across it already, but if not, you might find some inspiration from this post:

  
    
    
    Custom loss functions 
  
  
    Hi, 
I’m implementing a custom loss function in Pytorch 0.4. Reading the docs and the forums, it seems that there are two ways to define a custom loss function: 

Extending Function and implementing forward and backward methods.
Extending Module and implementing only the forward method.

With that in mind, my questions are: 

Can I write a python function that takes my model outputs as inputs and use torch.* functions to compute my loss function (without extending Function or Module)? If not, wh…