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 identifies the class associated with an example. In binary classification, there are two possible classes: for example, a handwritten digit can be labeled as a 1 or a 0. A target label gives the desired answer for an input, while a predicted label is the model’s answer. section 1.2 section 2.1

Labels can guide training by pairing each example with its desired class. A label need not always describe a whole image: in semantic segmentation, each pixel can have a binary label. True marks a nodule candidate, while false marks healthy tissue that is not of interest. section 1.2 section 15.2

Separating inputs and targets

In a wine dataset, chemical measurements can be inputs and the quality score can be treated as a classification label. The score is kept in a separate target tensor so it serves as ground truth without being fed into the model. This example uses scores rather than two binary classes. section 4.3.3

# In[5]:
data = wineq[:, :-1]     #1
data, data.shape

# Out[5]:
(tensor([[ 7.00,  0.27,  ...,  0.45,  8.80],
         [ 6.30,  0.30,  ...,  0.49,  9.50],
         ...,
         [ 5.50,  0.29,  ...,  0.38, 12.80],
         [ 6.00,  0.21,  ...,  0.32, 11.80]]), torch.Size([4898, 11]))

# In[6]:
target = wineq[:, -1]     #2
target, target.shape

# Out[6]:
(tensor([6., 6.,  ..., 7., 6.]), torch.Size([4898]))

See how tensor slicing separates the wine measurements from their target scores. section 4.3.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Defines labels as classes and illustrates their use as separate targets, without detailing binary metric computation.
Examples
Uses handwritten 1s and 0s and binary pixel labels for nodule candidates and healthy tissue.
What you can do after
Apply it via PyTorch tensor slicing to separate classification targets from input measurements.
How it connects
Connects labels to classification, ground truth, and semantic segmentation.

Also explained in

Compare how 21 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.