Skip to content

Commit ec672e4

Browse files
committed
Clarify label encoding comment in char_rnn_classification_tutorial
The previous comment 'Cache the tensor representation of the labels' was misleading, especially for beginners. The code actually creates a numerical representation by storing unique labels in alphabetical order and converting each label to its corresponding index as a tensor. Updated the comment to clearly explain what's happening: creating numerical representations rather than caching.
1 parent 86b1c62 commit ec672e4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

intermediate_source/char_rnn_classification_tutorial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def __init__(self, data_dir):
179179
self.data_tensors.append(lineToTensor(name))
180180
self.labels.append(label)
181181

182-
#Cache the tensor representation of the labels
182+
# Create numerical representation of labels
183+
# Store unique labels in alphabetical order and convert each label to its index
183184
self.labels_uniq = list(labels_set)
184185
for idx in range(len(self.labels)):
185186
temp_tensor = torch.tensor([self.labels_uniq.index(self.labels[idx])], dtype=torch.long)

0 commit comments

Comments
 (0)