dennybritz / nn-from-scratch

Implementing a Neural Network from Scratch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: cannot reshape array of size 200 into shape (328,461)

sukasenyumm opened this issue · comments

thanks for your great tutorial!

I have an issue when trying to plot "Decision Boundary for hidden layer size 3". Below the error:

ValueError Traceback (most recent call last)
in ()
1 # Plot hasil
----> 2 plot_decision_boundary(lambda x: predict(model, x))
3 plt.title("Decision Boundary for hidden layer size 3")

in plot_decision_boundary(pred_func)
28 # Predict the function value for the whole gid
29 Z = pred_func(np.c_[xx.ravel(), yy.ravel()])
---> 30 Z = Z.reshape(xx.shape)
31 # Plot the contour and training examples
32 plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral)

ValueError: cannot reshape array of size 200 into shape (328,461)

Is there any solution for this? Thank you

@sukasenyumm just check your predict function. You must have used the 'X' which was globally declared input rather than the x parameter of your predict function.

commented

In your predict function find z1 = X.dot(W1) + b1 and replace X.dot to x.dot.