PyTorch custom loss function

后端 未结 3 2001
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 07:46

How should a custom loss function be implemented ? Using below code is causing error :

import torch
import torch.nn as nn
import torchvision
import torchvision.         


        
3条回答
  •  一整个雨季
    2021-02-04 08:29

    Solution

    Here are a few examples of custom loss functions that I came across in this Kaggle Notebook. It provides an implementation of the following custom loss functions in PyTorch as well as TensorFlow.

    Loss Function Reference for Keras & PyTorch

    I hope this will be helpful for anyone looking to see how to make your own custom loss functions.

    • Dice Loss
    • BCE-Dice Loss
    • Jaccard/Intersection over Union (IoU) Loss
    • Focal Loss
    • Tversky Loss
    • Focal Tversky Loss
    • Lovasz Hinge Loss
    • Combo Loss

提交回复
热议问题