Caffe fork that supports training with weighted samples http://caffe.berkeleyvision.org/
C++ Python Cuda CMake Protocol Buffer Makefile Other
Clone or download
Latest commit e5c028f Aug 3, 2015
Permalink
Failed to load latest commit information.
CMakeScripts Fixed CMake script of FindOpenBLAS. Sep 8, 2014
data [example] image classification web demo Jul 12, 2014
docs [docs] re-title docs, count forks Oct 20, 2014
examples Fixing finetune_flickr_style model reported accuracy. Oct 17, 2014
include/caffe Made inputs optional in HDF5 data layer. Nov 25, 2014
matlab removed mention of getting_pretrained_models page and old paths Sep 4, 2014
models Fixing finetune_flickr_style model reported accuracy. Oct 17, 2014
python Updated pycaffe to include sample weights. Nov 5, 2014
scripts [model zoo] download from gist grooming Sep 19, 2014
src Made inputs optional in HDF5 data layer. Nov 25, 2014
tools default backend to lmdb for image conversion and mean computation Sep 21, 2014
.Doxyfile update doxygen config to stop warnings Sep 3, 2014
.gitignore [model zoo] ignore models -- only for reference or zoo Sep 19, 2014
.travis.yml restore "red X" build failures in Travis Sep 11, 2014
CMakeLists.txt add -fPIC flag to CMake build Sep 11, 2014
CONTRIBUTORS.md clarify the license and copyright terms of the project Aug 7, 2014
INSTALL.md replace bundled install instructions with link to site Feb 10, 2014
LICENSE clarify the license and copyright terms of the project Aug 7, 2014
Makefile Fix build error caused by pthread lib order Oct 20, 2014
Makefile.config.example add cuDNN to build Sep 7, 2014
README.md Link to newer repo Aug 3, 2015
caffe.cloc [fix] stop cloc complaint about cu type Sep 4, 2014

README.md

Caffe with weighted samples

This is a branch of Caffe that allows training with weighted samples. The branch is experimental, so not every layer is updated to fit this new paradigm, nor are unit tests updated (yet). It might also easily break, since it has not be throughly tested.

How it works

The input data in Caffe is normally an associate array with the keys "data" and "label". The sample weights are input through this data structure by adding another key called "sample_weight". The weights should have the same shape as the labels.

Now, sample_weight can be accessed just like data and label, so we need to make sure our network's data layer loads them in:

layers { # Your data layer
    # ...
    top: "data"
    top: "label"
    top: "sample_weight"
}

Connect them to your loss layer:

layers { # Your loss layer
    name: "loss"
    type: SOFTMAX_LOSS
    bottom: "ip1"  # or whatever name it might have
    bottom: "label"
    bottom: "sample_weight"
    top: "loss"
}

Features

Read sample_weight through:

  • HDF5
  • lmdb (untested)
  • leveldb (untested)

The layers that have been made to appreciate sample_weight are:

  • SOFTMAX_LOSS (label and sample_weight should be 1D)
  • EUCLIDEAN_LOSS (label and sample_weight should be 2D)

New layers althogether include:

  • SOFTMAX_CROSS_ENTROPY_LOSS (a multi-class generalization of SIGMOID_CROSS_ENTROPY_LOSS)

For now, sample_weight is required to be specified, both in the training and testing data (even though it is not used in the latter).

Original Caffe note

Caffe is a deep learning framework developed with cleanliness, readability, and speed in mind.
Consult the project website for all documentation.