Simple Neural Network (shapes images) Produces Same Outputs

Viewed 34

I work on a simple neural network for the detection of the forms, here is all the code on github: https://github.com/stodar/shapes/blob/main/saad.ipynb .

I get the same result even when I change the inputs, I redid the code several times but no result.

please do you have any idea?


corrects, wrongs = 0, 0

print('Target', '     Predicted', ' %')
for i in range(len(x_test)):
    input_vector = np.array(x_test[i], ndmin=2).T
    output_vector = np.dot(wh,  input_vector)
    output_vector = sigmoid(output_vector)
    output_vector = np.dot(wo, output_vector)
    res = sigmoid(output_vector)
    
    #Evaluate Model
    res_max = res.argmax()
    e = np.array(res_max)
    e = np.eye(3)[res_max]
    e.astype('int32')
    if np.array_equal(e,y_test[i]) :
        corrects += 1
    else:
        wrongs += 1
    
    print(y_test[i], ' ',e, '       ', np.max(res))
    
print("accuracy:", corrects / ( corrects + wrongs))
1 Answers

by looking on the github you added to your question, you can see that on the test dataset, the model is really really bad, it only predict the class 2 (look at the accuracy of 0.0). This is due to a bad training of your model or a too weak architecture (your model doesn't make the difference between class 0, 1 and 2. One question: if you want to use Neural Network for prediction, why don't you use traditional librairies like Tensorflow or torch instead of np.dot?

Related