Given that you have used sigmoid in that call, I’m guessing this is for the output layer, after you fall out of the loop. My guess is that your problem has to do with how the loop index variable works when you fall out of the loop. Try this experiment and watch what happens:
for ii in range(1,5):
print(f"ii = {ii}")
print(f"After loop ii = {ii}")
Have you seen the “dimensional analysis” thread for this particular test cell? It’s worth a look to get a clear picture of what you expect to happen at each layer. Reading that, notice that A2 is 3 x 4 and that is the correct input for layer 3, but in that case the W3 shape should be 1 x 3. But your W value is the shape of W2. Hmmmmm …