Can someone please explain the difference between W.shape[0] and W.shape[1]

Specifically referring to the code where we def my_dense (a_in, W, b, g)
Why do we take units = W.shape[1] specifically?

You didn’t tell us which notebook it is, so I have to assume you are talking about the Course 2 Week 1 Assignment.

Screenshot from 2022-08-09 08-36-54

If you read the Docstring about W, you can see that it has a shape of (n, j) and their meanings are also explained. For your question,

W.shape will give you (n, j).
W.shape[0] will give you n.
W.shape[1] will give you j.