From ec672e479dc152e965bc876f12233a60e189e4b2 Mon Sep 17 00:00:00 2001 From: Eduardo Patrocinio Date: Mon, 24 Nov 2025 10:16:00 -0500 Subject: [PATCH 1/2] 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. --- intermediate_source/char_rnn_classification_tutorial.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intermediate_source/char_rnn_classification_tutorial.py b/intermediate_source/char_rnn_classification_tutorial.py index 04cfb16f62..830cd7f16f 100644 --- a/intermediate_source/char_rnn_classification_tutorial.py +++ b/intermediate_source/char_rnn_classification_tutorial.py @@ -179,7 +179,8 @@ def __init__(self, data_dir): self.data_tensors.append(lineToTensor(name)) self.labels.append(label) - #Cache the tensor representation of the labels + # Create numerical representation of labels + # Store unique labels in alphabetical order and convert each label to its index self.labels_uniq = list(labels_set) for idx in range(len(self.labels)): temp_tensor = torch.tensor([self.labels_uniq.index(self.labels[idx])], dtype=torch.long) From c6f627bed0fb8e1308c328026667ba07846d1c23 Mon Sep 17 00:00:00 2001 From: sekyondaMeta <127536312+sekyondaMeta@users.noreply.github.com> Date: Tue, 25 Nov 2025 10:46:29 -0500 Subject: [PATCH 2/2] Update char_rnn_classification_tutorial.py --- intermediate_source/char_rnn_classification_tutorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intermediate_source/char_rnn_classification_tutorial.py b/intermediate_source/char_rnn_classification_tutorial.py index 830cd7f16f..3c1d616e08 100644 --- a/intermediate_source/char_rnn_classification_tutorial.py +++ b/intermediate_source/char_rnn_classification_tutorial.py @@ -180,7 +180,7 @@ def __init__(self, data_dir): self.labels.append(label) # Create numerical representation of labels - # Store unique labels in alphabetical order and convert each label to its index + # Store unique labels and convert each label to its index in the label vocabulary self.labels_uniq = list(labels_set) for idx in range(len(self.labels)): temp_tensor = torch.tensor([self.labels_uniq.index(self.labels[idx])], dtype=torch.long)