fix typo in comment

This commit is contained in:
rasbt 2024-06-09 06:14:02 -05:00
parent e1adeb14f3
commit f0e4c99bc3
7 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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