Skip to content

Instantly share code, notes, and snippets.

@MohanaRC
Created August 10, 2023 16:12
Show Gist options
  • Save MohanaRC/19541672456ee127f9cb096f9db7e737 to your computer and use it in GitHub Desktop.
Save MohanaRC/19541672456ee127f9cb096f9db7e737 to your computer and use it in GitHub Desktop.
def train_data_for_one_epoch():
"""
Function for computing the gradient and updating weights in each epoch.
"""
losses = []
# Iterate over batches of the dataset and call apply_gradient function
for step, (x_batch_train, y_batch_train) in enumerate(train):
logits, loss_value = apply_gradient(optimizer, model, x_batch_train, y_batch_train)
losses.append(loss_value)
train_acc_metric(y_batch_train, logits)
return losses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment