Problems with neural network structure

The arrays to be used are passed in as arguments, right? Just use those. So the question is, how many rows are in the X matrix that is passed as the first argument? We saw how to figure that out earlier in the notebook. Each numpy object has an “attribute” called “shape”. If I have a 2 dimensional numpy array called myArray and I write this code:

theShape = myArray.shape

Then the newly defined python variable called theShape, will be a “tuple” with two elements: the first element will be the number of rows in myArray and the second element will be the number of columns in myArray. So if I need the number of rows, that would be:

theRows = theShape[0]

Because indexing in python is “0-based”, right?

But I think the issue you are having is more fundamental. The variable shape_X was defined earlier in the notebook and has nothing to do with the value of X that was passed by that test case. You can clearly see that from the print statement outputs, right? It is always a mistake to reference global variables from the scope of your functions. If you don’t understand what I mean by that statement, you really should consider taking a python course first. I think we’ve already discussed that on another thread, right? :nerd_face:

1 Like