Git Product home page Git Product logo

weighted_softmax_loss_layer's Introduction

WeightedSoftmaxWithLossLayer

Introduction

WeightedSoftmaxLossLayer for Caffe is modified from SoftmaxWithLossLayer in Caffe. You could set the class weight of each class in the prototxt file. If it helps your research, please consider give me a Star.

Add to Caffe

  1. Clone this repository

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

    // Add the next contents to message SoftmaxParameter
    message SoftmaxParameter {
        // the next added for WeightedSoftmaxWithLossLayer
        // pos_mult: class weight, default = 1
        // pos_cid: class id, specify the class id repected to the class weight.
        repeated float pos_mult = 3;    // class weight, you should select appropriate id, such as 3.
        repeated float pos_cid = 4;     // class id
    }
    
  3. Add source files to your Caffe

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

How to use this layer

  1. Write codes such as follows in your prototxt file.
    layer {
        name: "weighted_loss"
        type: "WeightedSoftmaxWithLoss"
        bottom: "conv_cls"
        bottom: "label"
        top: "loss"
        include {
            phase: TRAIN
        }
        loss_param {
            ignore_label: 255
        }
        softmax_param {
            pos_cid: 0          # for class 0
            pos_mult: 2.3434    # the weight of class 0 is 2.3434
            pos_cid: 1          # for class 1
            pos_mult: 1.23456   # the weight of class 1 is 1.23456
                                # and etc.
        }
    }
    

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.