liveBook · Manning

Label

As explained in Deep Learning with R, Third Edition

Ground truth is the set of target annotations for a dataset, typically collected from human judgments or measurements.

A label is the class assigned to a particular sample. If a picture is annotated as containing a dog, “dog” is that picture’s label. The possible choices, such as “dog” and “cat,” are classes. The full set of targets for a dataset is its ground truth, or annotations; those targets are typically collected by humans. section 4.0

Digits and their labels

In MNIST, each handwritten-digit image has a corresponding label from 0 to 9. In R, `library(keras3); .[.[train_images, train_labels], .[test_images, test_labels]] <- dataset_mnist()` loads paired arrays. Training uses `fit(model, train_images, train_labels, epochs = 5, batch_size = 128)` to associate images with their labels. Later, `evaluate(model, test_images, test_labels)` checks predictions against labels for images held out of training. section 2.1

Keep the related terms distinct:

  • A prediction is what the model outputs; a target is what it should ideally output. Loss measures the distance between them. section 4.0
  • A classification label names a class. Binary classification chooses between two classes; multiclass classification chooses among more than two; multilabel classification can assign several labels to one sample. section 4.0
  • Not every target is a class label. A house price is a continuous regression target, and a forecasting target can be a future temperature. section 4.0 section 13.2.1
int_sequence <- seq(10)
dummy_dataset <- timeseries_dataset_from_array(
  data = head(int_sequence, -3),
  targets = tail(int_sequence, -3),
  sequence_length = 3,
  batch_size = 2
)

dummy_dataset_iterator <- as_array_iterator(dummy_dataset)

repeat {
  batch <- iter_next(dummy_dataset_iterator)
  if (is.null(batch)) break
  .[inputs, targets] <- batch
  for (r in 1:nrow(inputs))
    cat(sprintf("input: [ %s ]  target: %s\n",
                paste(inputs[r, ], collapse = " "), targets[r]))
  cat(strrep("-", 27), "\n")
}

input: [ 1 2 3 ]  target: 4

input: [ 2 3 4 ]  target: 5

---------------------------

input: [ 3 4 5 ]  target: 6

input: [ 4 5 6 ]  target: 7

---------------------------

input: [ 5 6 7 ]  target: 8

---------------------------

The sequence example makes target alignment visible: input `[1 2 3]` pairs with target `4`, `[2 3 4]` with `5`, and so on. These numerical forecasting targets are not class labels. section 13.2.1

Targets sometimes need preparation too. In a house-price regression example, dividing prices by 100,000 puts training targets on a smaller scale; multiplying predictions by 100,000 converts them back to dollars. This changes their numerical scale, not what they represent. section 4.3.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines labels, classes, targets, and ground truth, then demonstrates image–label pairing without detailing how annotations are collected.
Examples
Uses dog-and-cat image annotations, MNIST digit labels, and future-temperature targets to contrast class labels with other targets.
What it assumes
Introduces samples, classes, and labels by definition; assumes no understanding of every neural-network step in the initial example.
What you can do after
Apply it via Keras to pair MNIST images with labels for training and compare test predictions with held-out labels.
How it connects
Connects labels to classification, ground truth, predictions, loss, and evaluation while distinguishing them from continuous regression targets.

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 R, Third Edition. The section links point to the parts of the book it draws on.