Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyerror : 0 #55

Open
MalavikaAR opened this issue Sep 24, 2021 · 6 comments
Open

Keyerror : 0 #55

MalavikaAR opened this issue Sep 24, 2021 · 6 comments

Comments

@MalavikaAR
Copy link

I got an error while running the NumPy neural network code using my dataset,
"'DataFrame' object has no attribute 'reshape'".
Also then I ran using your dataset make_moons, and again I got an error
"Keyerror: 0".

ln [19]:
#Training
params_values = train(np.transpose(X_train), np.transpose(y_train.reshape((y_train.shape[0], 1))), NN_ARCHITECTURE, 10000, 0.01)[0]

KeyError Traceback (most recent call last)
in ()
1 # Training
----> 2 params_values = train(np.transpose(X_train), np.transpose(y_train.reshape((y_train.shape[0], 1))), NN_ARCHITECTURE, 10000, 0.01)[0]

KeyError: 0

Would you please help me with what to do?
Is it necessary to take the transpose and reshaping the X and y??

@SkalskiP
Copy link
Owner

Hi @MalavikaAR 👋. ! Judging by the error I think that you are trying to pass pandas.DataFrame instead of numpy.array through the neural network.

@MalavikaAR
Copy link
Author

Ohh, okay, I will try to change that in my dataset. But what was the issue in trying with make_moons??

@MalavikaAR
Copy link
Author

Heyy @SkalskiP , I changed it to numpyarray, and that error was gone, thankyou, but now I got the following error:


KeyError Traceback (most recent call last)
in ()
1 # Training
----> 2 params_values = train(np.transpose(X_train), np.transpose(y_train), NN_ARCHITECTURE, 10000, 0.01)

1 frames
in update(params_values, grads_values, nn_architecture, learning_rate)
1 def update(params_values, grads_values, nn_architecture, learning_rate):
2 for layer_idx, layer in enumerate(nn_architecture):
----> 3 params_values["W" + str(layer_idx)] -= learning_rate * grads_values["dW" + str(layer_idx)]
4 params_values["b" + str(layer_idx)] -= learning_rate * grads_values["db" + str(layer_idx)]
5

KeyError: 'W0'

Would you please help me? I noticed some other people have asked about the same error in your article in the 'medium'.

@SkalskiP
Copy link
Owner

@MalavikaAR could you please show me how did you use make_moons function?

@MalavikaAR
Copy link
Author

@SkalskiP

https://colab.research.google.com/drive/1dkvOMq2AYuHlTYLHodQzmro1kweY5W3O#scrollTo=e9-aFcBbNlsx

Please take a look at this link. I have tried it in colab.

@MalavikaAR
Copy link
Author

I just wanted to add, the error is gone when I deleted the last indexing [0] of ln: [19] and got an accuracy of 0.98.
But I am not sure if it is the right thing to do.

ln : [19]

Training

params_values = train(np.transpose(X_train), np.transpose(y_train.reshape((y_train.shape[0], 1))), NN_ARCHITECTURE, 10000, 0.01)[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants