mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2025-08-30 19:41:51 +00:00
fix typo in comment
This commit is contained in:
parent
e1adeb14f3
commit
f0e4c99bc3
@ -494,7 +494,7 @@ def train_classifier_simple(model, train_loader, val_loader, optimizer, device,
|
|||||||
model.train() # Set model to training mode
|
model.train() # Set model to training mode
|
||||||
|
|
||||||
for input_batch, target_batch in train_loader:
|
for input_batch, target_batch in train_loader:
|
||||||
optimizer.zero_grad() # Reset loss gradients from previous epoch
|
optimizer.zero_grad() # Reset loss gradients from previous batch iteration
|
||||||
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
||||||
loss.backward() # Calculate loss gradients
|
loss.backward() # Calculate loss gradients
|
||||||
optimizer.step() # Update model weights using loss gradients
|
optimizer.step() # Update model weights using loss gradients
|
||||||
|
@ -1230,7 +1230,7 @@
|
|||||||
" model.train() # Set model to training mode\n",
|
" model.train() # Set model to training mode\n",
|
||||||
" \n",
|
" \n",
|
||||||
" for input_batch, target_batch in train_loader:\n",
|
" for input_batch, target_batch in train_loader:\n",
|
||||||
" optimizer.zero_grad() # Reset loss gradients from previous epoch\n",
|
" optimizer.zero_grad() # Reset loss gradients from previous batch iteration\n",
|
||||||
" loss = calc_loss_batch(input_batch, target_batch, model, device)\n",
|
" loss = calc_loss_batch(input_batch, target_batch, model, device)\n",
|
||||||
" loss.backward() # Calculate loss gradients\n",
|
" loss.backward() # Calculate loss gradients\n",
|
||||||
" optimizer.step() # Update model weights using loss gradients\n",
|
" optimizer.step() # Update model weights using loss gradients\n",
|
||||||
@ -2477,7 +2477,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.11.4"
|
"version": "3.10.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
@ -84,7 +84,7 @@ def train_model_simple(model, train_loader, val_loader, optimizer, device, num_e
|
|||||||
model.train() # Set model to training mode
|
model.train() # Set model to training mode
|
||||||
|
|
||||||
for input_batch, target_batch in train_loader:
|
for input_batch, target_batch in train_loader:
|
||||||
optimizer.zero_grad() # Reset loss gradients from previous epoch
|
optimizer.zero_grad() # Reset loss gradients from previous batch iteration
|
||||||
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
||||||
loss.backward() # Calculate loss gradients
|
loss.backward() # Calculate loss gradients
|
||||||
optimizer.step() # Update model weights using loss gradients
|
optimizer.step() # Update model weights using loss gradients
|
||||||
|
@ -1871,7 +1871,7 @@
|
|||||||
" model.train() # Set model to training mode\n",
|
" model.train() # Set model to training mode\n",
|
||||||
"\n",
|
"\n",
|
||||||
" for input_batch, target_batch in train_loader:\n",
|
" for input_batch, target_batch in train_loader:\n",
|
||||||
" optimizer.zero_grad() # Reset loss gradients from previous epoch\n",
|
" optimizer.zero_grad() # Reset loss gradients from previous batch iteration\n",
|
||||||
" loss = calc_loss_batch(input_batch, target_batch, model, device)\n",
|
" loss = calc_loss_batch(input_batch, target_batch, model, device)\n",
|
||||||
" loss.backward() # Calculate loss gradients\n",
|
" loss.backward() # Calculate loss gradients\n",
|
||||||
" optimizer.step() # Update model weights using loss gradients\n",
|
" optimizer.step() # Update model weights using loss gradients\n",
|
||||||
@ -2371,7 +2371,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.11.4"
|
"version": "3.10.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
@ -201,7 +201,7 @@ def train_classifier_simple(model, train_loader, val_loader, optimizer, device,
|
|||||||
model.train() # Set model to training mode
|
model.train() # Set model to training mode
|
||||||
|
|
||||||
for input_batch, target_batch in train_loader:
|
for input_batch, target_batch in train_loader:
|
||||||
optimizer.zero_grad() # Reset loss gradients from previous epoch
|
optimizer.zero_grad() # Reset loss gradients from previous batch iteration
|
||||||
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
||||||
loss.backward() # Calculate loss gradients
|
loss.backward() # Calculate loss gradients
|
||||||
optimizer.step() # Update model weights using loss gradients
|
optimizer.step() # Update model weights using loss gradients
|
||||||
|
@ -120,7 +120,7 @@ def train_classifier_simple(model, train_loader, val_loader, optimizer, device,
|
|||||||
model.train() # Set model to training mode
|
model.train() # Set model to training mode
|
||||||
|
|
||||||
for input_batch, target_batch in train_loader:
|
for input_batch, target_batch in train_loader:
|
||||||
optimizer.zero_grad() # Reset loss gradients from previous epoch
|
optimizer.zero_grad() # Reset loss gradients from previous batch iteration
|
||||||
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
loss = calc_loss_batch(input_batch, target_batch, model, device)
|
||||||
loss.backward() # Calculate loss gradients
|
loss.backward() # Calculate loss gradients
|
||||||
optimizer.step() # Update model weights using loss gradients
|
optimizer.step() # Update model weights using loss gradients
|
||||||
|
@ -149,7 +149,7 @@ def train_classifier_simple(model, train_loader, val_loader, optimizer, device,
|
|||||||
model.train() # Set model to training mode
|
model.train() # Set model to training mode
|
||||||
|
|
||||||
for input_batch, target_batch in train_loader:
|
for input_batch, target_batch in train_loader:
|
||||||
optimizer.zero_grad() # Reset loss gradients from previous epoch
|
optimizer.zero_grad() # Reset loss gradients from previous batch iteration
|
||||||
loss = calc_loss_batch(input_batch, target_batch, model, device, trainable_token=trainable_token)
|
loss = calc_loss_batch(input_batch, target_batch, model, device, trainable_token=trainable_token)
|
||||||
loss.backward() # Calculate loss gradients
|
loss.backward() # Calculate loss gradients
|
||||||
optimizer.step() # Update model weights using loss gradients
|
optimizer.step() # Update model weights using loss gradients
|
||||||
|
Loading…
x
Reference in New Issue
Block a user