plot function does not plot curves just plotted legend in PyCharm
I am doing some homework about image classification using PyTorch. For this purpose I have visited the following link: https://github.com/Bjarten/early-stopping-pytorch/blob/master/MNIST_Early_Stopping_example.ipynb and obtained some results like this related to training losses and validation losses

[ 1/10] train_loss: 1.56952 valid_loss: 1.54557
Validation loss decreased (inf --&gt; 1.545571).  Saving model ...
[ 2/10] train_loss: 1.52198 valid_loss: 1.50932
Validation loss decreased (1.545571 --&gt; 1.509324).  Saving model ...
[ 3/10] train_loss: 1.48958 valid_loss: 1.48514
Validation loss decreased (1.509324 --&gt; 1.485136).  Saving model ...
[ 4/10] train_loss: 1.46960 valid_loss: 1.46938
Validation loss decreased (1.485136 --&gt; 1.469381).  Saving model ...


But the problem is that whenever I try to plot loss curves it does not show anything. 

my plotted figure

I would expect my curve to be like the one in this picture.
Here is the code that I used to draw this curve:

  # visualize the loss as the network trained
    fig = plt.figure(figsize=(10, 8))
    plt.plot(range(1, len(train_loss) + 1), train_loss, label='Training Loss')
    plt.plot(range(1, len(valid_loss) + 1), valid_loss, label='Validation Loss')

        # find position of lowest validation loss
    minposs = valid_loss.index(min(valid_loss)) + 1
    plt.axvline(minposs, linestyle='--', color='r', label='Early Stopping Checkpoint')

    plt.xlabel('epochs')
    plt.ylabel('loss')
    plt.ylim(0, 0.5)  # consistent scale
    plt.xlim(0, len(train_loss) + 1)  # consistent scale
    plt.grid(True)
    plt.legend()
    plt.tight_layout()
    plt.show()
    fig.savefig('loss_plot.png', bbox_inches='tight')


Here is the value of length of the training loss and the testing loss

len of train loss: 1
train loss :[1.6059992909431458]


Since len(train_loss) == 1 and train_loss = [1.6059992909431458], your plot is exactly the same as if you called plt.plot(range(1, 2), [1.6059992909431458]), which, as you can check, is empty (this is because plt.plot draws lines between data points, and as there is a single data point, there can be no line drawn). You can change plt.plot to plt.scatter in order to see that single data point.

So this problem has nothing to do with plotting really, and you should rather figure out why your algorithm only runs for a single epoch and troubleshoot that, rather than plotting.
