From 8338733af27114c9cd06f080d77c778ef48dff1a Mon Sep 17 00:00:00 2001 From: Vijay Janapa Reddi Date: Tue, 28 Oct 2025 12:21:30 -0400 Subject: [PATCH] fix(milestones): Improve tinystories_gpt.py training output frequency - Changed logging from every 20 batches to every 10 batches - Show first batch immediately for instant feedback - Display both current loss and running average - Format: 'Batch X/500 | Loss: X.XXXX | Avg: X.XXXX' This provides continuous visual feedback during training so users can see the model learning in real-time. --- milestones/05_2017_transformer/tinystories_gpt.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/milestones/05_2017_transformer/tinystories_gpt.py b/milestones/05_2017_transformer/tinystories_gpt.py index fa89194b..3ae075fd 100644 --- a/milestones/05_2017_transformer/tinystories_gpt.py +++ b/milestones/05_2017_transformer/tinystories_gpt.py @@ -354,9 +354,10 @@ def train_tinystories_gpt(model, train_loader, dataset, epochs=5, learning_rate= epoch_loss += loss_value batch_count += 1 - # Progress - if (batch_idx + 1) % 20 == 0: - console.print(f" Batch {batch_idx+1}: Loss = [cyan]{loss_value:.4f}[/cyan]") + # Progress - show output frequently so user sees continuous training + if batch_idx == 0 or (batch_idx + 1) % 10 == 0 or (batch_idx + 1) % 50 == 0: + avg_loss = epoch_loss / batch_count + console.print(f" Batch {batch_idx+1}/500 | Loss: {loss_value:.4f} | Avg: {avg_loss:.4f}") # Epoch summary avg_loss = epoch_loss / max(1, batch_count)