Plotting loss curve from training loop

hello, I am looking for a way to plot the loss curve in my training loop pytorch. Any ideas on how do I do it? I cant find the right one for me

for epoch in range(num_epochs):
train_loss = 0.0
valid_loss = 0.0

model.train() # prep model for training
for it, training_data in enumerate(training_loader):
    training_label = training_data[0]
    output = model(training_input)
    loss = criterion(output, training_label)

    # update running training loss
    if it % 25 == 0:
        print(f"loss at step {it}: {loss}")
    if it == 50000:
1 Like

Have you seen this?

1 Like

I did. However, it is not a loss curve graph. I am looking for something like a matplotlib.

I am currently considering printing out the loss and graph it in excel

Once you get the loss, package like matplotlib can be used to plot the loss.
Please explain in detail on what the issue is.

I wasnt able to implement the matplotlib and I cant find anythin on the internet that works for mine

I think its because I didnt have grad=true?

Please click my name and message your file as an attachment.

Hey, I am very sorry. I just found out how to do it just now and felt really. Its only declaring loss array and .append function to store the loss.