Giter Club home page Giter Club logo

focal_loss_layer's Introduction

FocalLossLayer

Introduction

FocalLossLayer is midified from SoftmaxWithLossLayer. More info please refer to paper: Focal Loss for Dense Object Detection. If it helps your research, Please consider give me a Star.

Add to caffe

  1. Clone this repository

    git clone https://github.com/liaomingg/focal_loss_layer.git
  2. Modify your caffe.proto

    // Add the next contents to message LayerParameter
    message LayerParameter {
        optional FocalLossParameter focal_loss_param = 151; // select a id.
    }
    
    // Add the next contents to your caffe.proto
    // Message that stores parameter used by FocalLossLayer
    message FocalLossParameter {
        // loss = -alpha * (1 - pk)^gamma * ln(pk)
        // alpha is a parameter which scale the loss
        optional float alpha = 1 [default = 0.25];
        optional float gamma = 2 [default = 2.00];
    }
    
  3. Add source file to your Caffe

    Add focal_loss_layer.hpp to Caffe/include/caffe/layers/
    Add focal_loss_layer.cpp to Caffe/src/caffe/layers/
    Add focal_loss_layer.cu to Caffe/src/caffe/layers/
    
  4. Compile your Caffe

How to use it ?

  1. Write codes such as follows in your prototxt file.
    layer {
        name: "focal_loss"
        type: "FocalLoss"
        bottom: "conv_cls"
        bottom: "label"
        top: "loss"
        include {
            phase: TRAIN
        }
        loss_param {
            ignore_label: 255
        }
        focal_loss_param {
            alpha: 0.25
            gamma: 2.00
        }
    }
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.