Update train.py
Browse files
train.py
CHANGED
|
@@ -101,7 +101,7 @@ def train(dataloader, model, loss_fn, optimizer):
|
|
| 101 |
|
| 102 |
train_loss /= num_batches
|
| 103 |
train_accuracy = 100. * correct.item() / size
|
| 104 |
-
print(
|
| 105 |
return train_loss,train_accuracy
|
| 106 |
|
| 107 |
def test(dataloader, model, loss_fn):
|
|
@@ -118,7 +118,7 @@ def test(dataloader, model, loss_fn):
|
|
| 118 |
correct += (pred.argmax(1) == y).type(torch.float).sum().item()
|
| 119 |
test_loss /= num_batches
|
| 120 |
correct /= size
|
| 121 |
-
print(f"Test
|
| 122 |
test_accuracy = 100*correct
|
| 123 |
return test_loss, test_accuracy
|
| 124 |
|
|
|
|
| 101 |
|
| 102 |
train_loss /= num_batches
|
| 103 |
train_accuracy = 100. * correct.item() / size
|
| 104 |
+
print(f"Train Metric: \n Accuracy: {(100*correct):>0.1f}% \n")
|
| 105 |
return train_loss,train_accuracy
|
| 106 |
|
| 107 |
def test(dataloader, model, loss_fn):
|
|
|
|
| 118 |
correct += (pred.argmax(1) == y).type(torch.float).sum().item()
|
| 119 |
test_loss /= num_batches
|
| 120 |
correct /= size
|
| 121 |
+
print(f"Test Metrics: \n Accuracy: {(100*correct):>0.1f}%, Avg loss: {test_loss:>8f} \n")
|
| 122 |
test_accuracy = 100*correct
|
| 123 |
return test_loss, test_accuracy
|
| 124 |
|