0

This is a very basic question, however, its been puzzling me a lot, Apologize for being a novice.

I have graphs like below plotted on python, I have realized that the white grid at the background is sometimes there and if I run the same code another time, sometimes the grid is not there and is replaced by an overall black outline.

There should be logic for it but I fail to find it. Is there a way to ensure that the grid stays? I am using google-colab.

below is the part of my code responsible for this graph.

def NeuralNetwork(X_train, Y_train, X_val, Y_val, epochs, nodes, lr):
    hidden_layers = len(nodes) - 1
    weights = InitializeWeights(nodes)
    Training_accuracy=[]
    Validation_accuracy=[]
    for epoch in range(1, epochs+1):
        weights  = Train(X_train, Y_train, lr, weights)

        if (epoch % 1 == 0):
            print("Epoch {}".format(epoch))
            print("Training Accuracy:{}".format(Accuracy(X_train, Y_train, weights)))
            
            if X_val.any():
                print("Validation Accuracy:{}".format(Accuracy(X_val, Y_val, weights)))
            Training_accuracy.append(Accuracy(X_train, Y_train, weights))
            Validation_accuracy.append(Accuracy(X_val, Y_val, weights))
    plt.plot(Training_accuracy) 
    plt.plot((Validation_accuracy),'#008000') 
    plt.legend(["Training_accuracy", "Validation_accuracy"])    
    plt.xlabel("Epoch")
    plt.ylabel("Accuracy")  
    return weights , Training_accuracy , Validation_accuracy

enter image description here

user157522
  • 372
  • 2
  • 11

0 Answers0