VL_NNLOSS - CNN categorical or attribute loss.

Y = VL_NNLOSS(X, C) computes the loss incurred by the prediction scores X given the categorical labels C.

The prediction scores X are organised as a field of prediction vectors, represented by a H x W x D x N array. The first two dimensions, H and W, are spatial and correspond to the height and width of the field; the third dimension D is the number of categories or classes; finally, the dimension N is the number of data items (images) packed in the array.

While often one has H = W = 1, the case W, H > 1 is useful in dense labelling problems such as image segmentation. In the latter case, the loss is summed across pixels (contributions can be weighed using the InstanceWeights option described below).

The array C contains the categorical labels. In the simplest case, C is an array of integers in the range [1, D] with N elements specifying one label for each of the N images. If H, W > 1, the same label is implicitly applied to all spatial locations.

In the second form, C has dimension H x W x 1 x N and specifies a categorical label for each spatial location.

In the third form, C has dimension H x W x D x N and specifies attributes rather than categories. Here elements in C are either

can be active at the same time, while categories are mutually exclusive. By default, the loss is summed across attributes (unless otherwise specified using the InstanceWeights option described below).

DZDX = VL_NNLOSS(X, C, DZDY) computes the derivative of the block projected onto the output derivative DZDY. DZDX and DZDY have the same dimensions as X and Y respectively.

VL_NNLOSS() supports several loss functions, which can be selected by using the option type described below. When each scalar c in C is interpreted as a categorical label (first two forms above), the following losses can be used:

When C is a vector of binary attribures c in (+1,-1), each scalar prediction score x is interpreted as voting for the presence or absence of a particular attribute. The following losses can be used:

VL_NNLOSS(...,'OPT', VALUE, ...) supports these additionals options:

See also: VL_NNSOFTMAX().