liveBook · Manning

Label

As explained in Deep Learning with PyTorch, Second Edition

A target label restricted to one of two classes, used here in binary classification and metric computation.

A label names the answer a model is meant to predict. In image classification, “label” and “class” can mean the same thing. A label is not always binary: an image classifier may choose among 1,000 classes. In a binary task, the target is restricted to two classes, such as handwritten 1 versus 0. section 2.1 section 1.2

Keep the target separate from the inputs. For wine data, chemical measurements form the input tensor, while the quality score is held in a target tensor. Treating that score as a label makes the task classification rather than regression; labels can be stored as integer indices. section 4.3.3

A binary label for each pixel

In a medical-image segmentation task, each pixel receives a true or false label: true marks a nodule candidate, and false marks uninteresting healthy tissue. Together, those labels form a mask of areas of interest. section 15.2

# In[6]:
img, label = cifar10[99]
img, label, class_names[label]

# Out[6]:
(<PIL.Image.Image image mode=RGB size=32x32>, 1, 'automobile')

A PyTorch dataset returns an image and its integer label; looking up that index gives the class name “automobile.” section 7.1.2

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Defines label alongside class and demonstrates target storage and binary masks, without a metric-computation procedure.
Examples
Illustrates labels with handwritten 1s versus 0s, wine-quality scores, an automobile image, and true-or-false nodule pixels.
What it assumes
Introduces label and class terminology directly, then uses basic tensor indexing and image-classification examples.
What you can do after
Evaluate/understand whether a target is a two-class label and keep it distinct from input data.
How it connects
Connects labels to classification, regression, ground truth, PyTorch Dataset, and semantic segmentation.

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