In function predict:
p = np.zeros((1,m), dtype = np.int)
There exists no numpy method (dtype) int.
It shold be np.int_ or better np.intc here.
Calling predictions_train = predict(train_X, train_Y, parameters)
causes an error: AttributeError: module ‘numpy’ has no attribute ‘int’
I am using this file because I work offline on my laptop. Have not yet passed any code to online notebook, but I suppose the same effect.
This is the Initialization Assignment. I just reran it with no problems on the course website. I think we’d know about it if this bug existed in the online notebooks. I mean that the code does really look that way in the online environment, but it works fine. So this is most likely a “versionitis” problem. Everything evolves pretty quickly in the world of python and associated packages. You can’t just assume that any piece of code will work with an arbitrary collection of versions of the various supporting software. This is what “anaconda” is for: to let you assemble a matching collection of packages to solve this type of problem.
It’s also pretty obvious how to fix that particular thing in the local version you have. I would agree that the code is kind of silly. Why bother to muck with the type on the np.zeros
call, since float will work fine and you’re about to rewrite it with Boolean values in any case. Even that doesn’t matter because of the type coercion rules. So what’s the real point of that dtype argument?
But fixing that is just the first landmine and who knows how many more there are waiting to be gently stepped upon. There are no official instructions for how to use Anaconda to setup a matching local environment, but here’s a thread that will get you started down that road.
1 Like
Sure it is no problem for myself, I just changed it locally to np.intc.
In question of setting up the virtual environment - it is ok to do it, and simple to making.
I see I have newer versions as well np as python than are using by Cursera and that causes errors. I’ll fix it.