From 88ff2c2b724e8ab5d070a4a3b67a41a99724c5d7 Mon Sep 17 00:00:00 2001 From: Kobiljon Erkinjonov Date: Tue, 6 Oct 2026 15:09:32 +0000 Subject: [PATCH] Fix minibatch splitting in char-RNN classification tutorial --- 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 04cfb16f627..8b7e43bf23d 100644 --- a/intermediate_source/char_rnn_classification_tutorial.py +++ b/intermediate_source/char_rnn_classification_tutorial.py @@ -316,7 +316,8 @@ def train(rnn, training_data, n_epoch = 10, n_batch_size = 64, report_every = 50 # we cannot use dataloaders because each of our names is a different length batches = list(range(len(training_data))) random.shuffle(batches) - batches = np.array_split(batches, len(batches) //n_batch_size ) + n_batches = (len(batches) + n_batch_size - 1) // n_batch_size + batches = np.array_split(batches, n_batches) for idx, batch in enumerate(batches): batch_loss = 0