Ubuntu commited on
Commit
5005854
·
1 Parent(s): 41b8141

added table to the training logs to copy to Excel

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. resnet_execute.py +12 -0
.gitignore CHANGED
@@ -3,4 +3,6 @@ data/
3
  __pycache__
4
  ResNet 50_Model.xlsx
5
  ~$ResNet 50_Model.xlsx
 
 
6
 
 
3
  __pycache__
4
  ResNet 50_Model.xlsx
5
  ~$ResNet 50_Model.xlsx
6
+ checkpoint.pth
7
+
8
 
resnet_execute.py CHANGED
@@ -105,10 +105,17 @@ if __name__ == '__main__':
105
  except FileNotFoundError:
106
  print("No checkpoint found, starting from scratch.")
107
 
 
 
 
108
  for epoch in range(1, 6): # 20 epochs
109
  train_accuracy = train(model, device, trainloader, optimizer, criterion, epoch)
110
  test_accuracy, test_loss = test(model, device, testloader, criterion)
111
  print(f'Epoch {epoch} | Train Accuracy: {train_accuracy:.2f}% | Test Accuracy: {test_accuracy:.2f}%')
 
 
 
 
112
  if test_loss < best_loss:
113
  best_loss = test_loss
114
  patience_counter = 0
@@ -119,3 +126,8 @@ if __name__ == '__main__':
119
  if patience_counter >= patience:
120
  print("Early stopping triggered. Training terminated.")
121
  break
 
 
 
 
 
 
105
  except FileNotFoundError:
106
  print("No checkpoint found, starting from scratch.")
107
 
108
+ # Store results for each epoch
109
+ results = []
110
+
111
  for epoch in range(1, 6): # 20 epochs
112
  train_accuracy = train(model, device, trainloader, optimizer, criterion, epoch)
113
  test_accuracy, test_loss = test(model, device, testloader, criterion)
114
  print(f'Epoch {epoch} | Train Accuracy: {train_accuracy:.2f}% | Test Accuracy: {test_accuracy:.2f}%')
115
+
116
+ # Append results for this epoch
117
+ results.append((epoch, train_accuracy, test_accuracy))
118
+
119
  if test_loss < best_loss:
120
  best_loss = test_loss
121
  patience_counter = 0
 
126
  if patience_counter >= patience:
127
  print("Early stopping triggered. Training terminated.")
128
  break
129
+
130
+ # Print the results in a tab-separated format
131
+ print("\nEpoch\tTrain Accuracy\tTest Accuracy")
132
+ for epoch, train_acc, test_acc in results:
133
+ print(f"{epoch}\t{train_acc:.2f}\t{test_acc:.2f}")