pytorch-deep-learning icon indicating copy to clipboard operation
pytorch-deep-learning copied to clipboard

Plot loss Curve error

Open Valen-Nneji-007 opened this issue 1 year ago • 4 comments

After writing the code from video 159, plotting the loss curve of model 0, I got a disturbing error, that I don't understand.. Loss curve error

Valen-Nneji-007 avatar Jul 28 '24 21:07 Valen-Nneji-007

It is one of the error, which were introduced in beginning shape error. Here you must have same shape for first dimension, however in your case there is different shape of x and y. This might occur when you are declaring x or y.

Image is not having enough data, You should provide model_0_results and plot_loss_curves function (if you made it) for better understanding to proble.

pritesh2000 avatar Aug 08 '24 08:08 pritesh2000

model_0_results plot loss curve

Valen-Nneji-007 avatar Aug 09 '24 14:08 Valen-Nneji-007

In here I don't see any problems. So if you want to troubleshoot see the result of model_0_results and make sure that train_loss and test_loss have same length, also same for train_acc and test_acc.

If this doesn't resolve issue, then put print statement in each block of function plot_loss_curves like,

plt.figure(figsize=(15, 7))
print("plt.figure is working")
plt.plot(epochs, accuracy, label= "train_accuracy")
print("plt.plot train_accuracy is working")

This will give you an idea of what is causing this error.

In your code you put label= "train_accuracy" in both accuracy and test_accuracy this isn't causing any error but still change it for better understanding.

If this error still bothers you, ask me again.

pritesh2000 avatar Aug 09 '24 19:08 pritesh2000

hey, Does this work or not ?

pritesh2000 avatar Aug 20 '24 08:08 pritesh2000