Skip to content

Commit 574b070

Browse files
committed
clarifying language based on svekars' feedback
1 parent 73991de commit 574b070

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

intermediate_source/char_rnn_classification_tutorial.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
2626
Specifically, we'll train on a few thousand surnames from 18 languages
2727
of origin, and predict which language a name is from based on the
28-
spelling:
28+
spelling.
2929
3030
Recommended Preparation
3131
=======================
@@ -79,8 +79,8 @@
7979
# line, mostly romanized (but we still need to convert from Unicode to
8080
# ASCII).
8181
#
82-
# The first thing we need to define and clean our data. First off, we need to convert Unicode to plain ASCII to
83-
# limit the RNN input layers. This is accomplished by converting Unicode strings to ASCII and allowing a small set of allowed characters (allowed_characters)
82+
# The first step is to define and clean our data. Initially, we need to convert Unicode to plain ASCII to
83+
# limit the RNN input layers. This is accomplished by converting Unicode strings to ASCII and allowing only a small set of allowed characters.
8484

8585
import string
8686
import unicodedata
@@ -141,9 +141,9 @@ def lineToTensor(line):
141141
# Congratulations, you have built the foundational tensor objects for this learning task! You can use a similar approach
142142
# for other RNN tasks with text.
143143
#
144-
# Next, we need to combine all our examples into a dataset so we can train, text and validate our models. For this,
145-
# we will use the `Dataset and DataLoader <https://pytorch.org/tutorials/beginner/basics/data_tutorial.html>` classes
146-
# to hold our dataset. Each Dataset needs to implement three functions: __init__, __len__, and __getitem__.
144+
# Next, we need to combine all our examples into a dataset so we can train, test and validate our models. For this,
145+
# we will use the `Dataset and DataLoader <https://pytorch.org/tutorials/beginner/basics/data_tutorial.html>`__ classes
146+
# to hold our dataset. Each Dataset needs to implement three functions: ``__init__``, ``__len__``, and ``__getitem__``.
147147
from io import open
148148
import glob
149149
import os
@@ -194,7 +194,7 @@ def __getitem__(self, idx):
194194

195195

196196
#########################
197-
#Here we can load our example data into the NamesDataset
197+
#Here we can load our example data into the ``NamesDataset``
198198

199199
alldata = NamesDataset("data/names")
200200
print(f"loaded {len(alldata)} items of data")
@@ -286,8 +286,8 @@ def label_from_output(output, output_labels):
286286
#
287287
# We do this by defining a train() function which trains on a given dataset with minibatches. RNNs
288288
# train similar to other networks so for completeness we include a batched training method here.
289-
# The loop (for i in batch) computes the losses for each of the items in the batch before adjusting the
290-
# weights. This is repeated until the number of epochs is reached.
289+
# The loop (``for i in batch``) computes the losses for each of the items in the batch before adjusting the
290+
# weights. This operation is repeated until the number of epochs is reached.
291291

292292
import random
293293
import numpy as np
@@ -338,7 +338,7 @@ def train(rnn, training_data, n_epoch = 10, n_batch_size = 64, report_every = 50
338338
return all_losses
339339

340340
##########################################################################
341-
# We can now train a dataset with mini batches for a specified number of epochs
341+
# We can now train a dataset with minibatches for a specified number of epochs
342342

343343
start = time.time()
344344
all_losses = train(rnn, train_set, n_epoch=55, learning_rate=0.15, report_every=5)
@@ -425,9 +425,9 @@ def evaluate(rnn, testing_data, classes):
425425
#
426426
# - Get better results with a bigger and/or better shaped network
427427
#
428-
# - Vary the hyperparameters to improve performance (e.g. change epochs, batch size, learning rate )
428+
# - Adjust the hyperparameters to enhance performance, such as changing the number of epochs, batch size, and learning rate
429429
# - Try the ``nn.LSTM`` and ``nn.GRU`` layers
430-
# - Change the size of the layers (e.g. fewer or more hidden nodes, additional linear layers)
430+
# - Modify the size of the layers, such as increasing or decreasing the number of hidden nodes or adding additional linear layers
431431
# - Combine multiple of these RNNs as a higher level network
432432
#
433433
# - Try with a different dataset of line -> label, for example:

0 commit comments

Comments
 (0)