What's the meaning of label mask?

In CnnSentenceDataSetIterator, there is no label mask for the data set, which is
DataSet ds = new DataSet(features, labels, featuresMask, null);

but in SentimentExampleIterator, you need to specify label mask expicitly, which is
labelsMask.putScalar(new int{i,lastIdx-1},1.0);

What’s the difference?

The label mask is only used in cases where you have a sequence output.

As you can see the sentiment example uses an RnnOutputLayer, that means that it has an output at each timestep. In this example we only have a label for the last step, so we have to mask out all the other steps.

In contrast to that the cnn sentence classification example is using an OutputLayer, that means it will only output a single result. In this case we don’t need a label mask, because there is nothing to mask out.