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




















