I am trying to plot the graph for validation/training accuracy and validation/training loss for a ResNet model.
Here is how I am training it:
LR = 0.01
N_EPOCHS = 50
BATCH_SIZE = 128

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")


resnet50 = models.resnet50(pretrained=True)

# Change the last layer
num_ftrs = resnet50.fc.in_features
resnet50.fc = nn.Linear(num_ftrs, 9)

model = resnet50.to(device)
optimizer = torch.optim.SGD(model.parameters(), lr=LR)
criterion = nn.CrossEntropyLoss()

print("Starting training loop...")
for epoch in range(N_EPOCHS):
    model.train()
    loss_train = 0
    for iter, traindata in enumerate(train_loader):
        train_inputs, train_labels = traindata
        train_inputs, train_labels = train_inputs.to(device), train_labels.to(device)
        optimizer.zero_grad()
        logits = model(train_inputs)
        loss = criterion(logits, train_labels)
        loss.backward()
        optimizer.step()
        loss_train += loss.item()
        #torch.save(model.state_dict(), "project.pt")
        print('Batch {} and Loss {:.5f}'.format(iter,loss_train/BATCH_SIZE))
    #model.load_state_dict(torch.load("project.pt"))
    model.eval()

    with torch.no_grad():
        for iter, valdata in enumerate(valid_loader, 0):
            val_inputs, val_labels = valdata
            val_inputs1, val_labels1 = val_inputs.to(device), val_labels.to(device)
            y_test_pred = model(val_inputs1)
            tar_=val_labels.cpu().numpy()
            loss = criterion(y_test_pred, val_labels1)
            print('Validation Loss {:.5f}'.format(loss.item()))

    print("Epoch {} | Train Loss {:.5f}".format( epoch, loss_train/BATCH_SIZE))

Any idea on how I could plot both graphs (accuracies and losses)? Thanks