I am working on Logistic regression with neural network mindset and I confused about using np.zeros in initializing parameters. I looked into numpy.zeros documentation and it was written i could use np.zeros(no of column, no of rows). So I tried np.zeros(dim,1) but error occurs datatype not understood. Am i missing something?
According to this documentation numpy.zeros receives as first argument the shape of the array, this could be a tuple or an int, and as second argument the type of data, hence the error.
In this case I think you should use as first argument a tuple in this form:
Hi thanks for replying. But I cant quite get what you are saying. Actually ‘dim’ is a variable whose value is to be entered by the user. The exercise requires the output of the code to be a column vector i.e. if dim=2 then column vector shape is (2,1). I have to initialize zeros in column vector of (dim,1) shape but i am getting error. Am I still missing something?
I think the problem is in the parentheses. “
(dim1, dim2)” is the first argument in itself. I used dim1 and dim2 as an example, in your particular case that could be (dim, 1) or whatever values you need for the shape of the array.
Without the inner parentheses
dim becomes the first argument and
1 the second argument, which is not what the function is expecting.
This was solved by @pankit himself.
It was the initialization of a float value on variable
However, I want to note that the issue correspond to Course 1, week 2, assignment 2.