Created
August 10, 2023 17:11
-
-
Save MohanaRC/84e85ffc732f81a9ac5d8d4e034b9e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = base_model() | |
# Iterate over epochs | |
epochs = 10 | |
epochs_val_losses, epochs_train_losses = [], [] | |
for epoch in range(epochs): | |
print('Start of epoch %d' % (epoch,)) | |
#Perform training using gradient tape | |
losses_train = train_data_for_one_epoch() | |
train_acc = train_acc_metric.result() | |
#Perform validation | |
losses_val = perform_validation() | |
val_acc = val_acc_metric.result() | |
#Compute mean training and validation loss in the epoch | |
losses_train_mean = np.mean(losses_train) | |
losses_val_mean = np.mean(losses_val) | |
epochs_val_losses.append(losses_val_mean) | |
epochs_train_losses.append(losses_train_mean) | |
print('\n Epoch %s: Train loss: %.4f Validation Loss: %.4f, Train Accuracy: %.4f, Validation Accuracy %.4f' % (epoch, float(losses_train_mean), float(losses_val_mean), float(train_acc), float(val_acc))) | |
train_acc_metric.reset_states() | |
val_acc_metric.reset_states() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment