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



















