Skip to content

Instantly share code, notes, and snippets.

View gombru's full-sized avatar

Raúl Gómez gombru

View GitHub Profile
@gombru
gombru / FocalLoss.py
Last active November 13, 2022 12:43
Caffe Python layer Focal Loss implementation (From Focal Loss for Dense Object Detection, Facebook paper)
import caffe
import numpy as np
import json
class FocalLoss(caffe.Layer):
"""
Compute Focal Loss
Inspired by https://arxiv.org/abs/1708.02002
Raul Gomez Bruballa
https://gombru.github.io/
@gombru
gombru / CustomSoftmaxLoss.py
Created May 22, 2018 16:17
Caffe Python layer implementing Cross-Entropy with Softmax activation Loss to deal with multi-label classification, were labels can be input as real numbers
import caffe
import numpy as np
class CustomSoftmaxLoss(caffe.Layer):
"""
Compute Cross Entropy loss with Softmax activations for multi-label classifications, accepting real numbers as labels
Inspired by https://arxiv.org/abs/1805.00932
Raul Gomez Bruballa
https://gombru.github.io/
"""