liveBook · Manning

Label

As explained in Deep Learning with Python, Third Edition

The desired output values that a model is trained to match for each input example.

A label says which class an input belongs to. If a picture is annotated as a dog, “dog” is that picture’s label; “dog” and “cat” are possible classes. The broader term target means the output a model should ideally predict, so a continuous house price is a target but not a class label. Predictions are compared with targets to measure error. section 4.0

A review and its label

In the IMDb dataset, each review is an input and its sentiment is the label. The arrays `train_labels` and `test_labels` contain 0s for negative reviews and 1s for positive reviews. The number is an encoding of the class, not a word from the review. section 4.1.1

>>> train_data[0]
[1, 14, 22, 16, ... 178, 32]
>>> train_labels[0]
1

Compare `train_data[0]`, a review encoded as word indices, with `train_labels[0]`, its expected class encoded as `1`. section 4.1.1

Decide what labels mean before collecting them:

  • Choose the classes for the task, then annotate examples consistently. A photo search project, for instance, first needs a set of image categories and then tagged images. section 6.1.2
  • Check whether an input can have one label or several. An image containing both a cat and a dog can carry both labels in multilabel classification. section 4.0
  • Treat label reliability as a dataset concern, not an afterthought: it is one of the data properties that affects generalization. section 6.1.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines labels against classes and targets, then illustrates encoded labels with IMDb arrays; does not detail an annotation procedure.
Examples
Uses dog and cat image annotations, manually tagged project datasets, and IMDb review labels encoded as 0 or 1.
What it assumes
Defines sample, prediction, target, class, and label rather than assuming familiarity with classification terminology.
What you can do after
Evaluate/understand which expected class belongs to each classification input and why reliable annotations matter.
How it connects
Connects labels to targets, classes, prediction error, multilabel classification, dataset collection, and generalization.

Also explained in

Compare how 20 books explain label →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.