From your error message:
"TypeError: arange: scalar arguments expected instead of a tuple."
It sounds to me like you are trying to use the shape of an existing array to define the shape of a new array using np.arange.
Your problem is that you don't understand what x.shape is giving you.
For example:
x = np.array([[1,2,3],[4,5,6]])
x.shape
produces (2,3), a tuple. If I try to use just x.shape to define a argument in np.arange like this:
np.arange(x.shape)
I get the following error:
"arange: scalar arguments expected instead of a tuple."
Reason being np.arange accepts either a scalar (which creates an array starting at 0 and increasing by 1 to the length provided) or 3 scalars which define where to start and end the array and the step size. You are giving it a tuple instead which it doesn't like.
So when you do:
np.arange(x.shape[0])
you are giving the arange function the first scalar in the tuple provided by x.shape and in my example producing an array like this [0,1] because the first index in the tuple is 2.
If I alternatively did
np.arange(x.shape[1])
I would get an array like [0,1,2] because the second index in the tuple is a 3.
If I did any of the following,
np.arange(x.shape[2])
np.arange(x.shape[1000])
np.arange(x.shape[300])
I would get an error because the tuple created by x.shape has only two dimensions and so can't be indexed any further than 0 or 1.
Hope that helps!