-
Note: Newer version: https://github.com/gustavla/caffe/tree/gustav
This offers the same functionality in a less invasive way, which means it can be kept up-to-date with the master branch much easier.
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.
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"
}
Read sample_weight
through:
- HDF5
- lmdb (untested)
- leveldb (untested)
The layers that have been made to appreciate sample_weight
are:
- SOFTMAX_LOSS (
label
andsample_weight
should be 1D) - EUCLIDEAN_LOSS (
label
andsample_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).
Caffe is a deep learning framework developed with cleanliness, readability, and speed in mind.
Consult the project website for all documentation.