Hi,
I think that you are trying to run the loop over the entire 30000 batch instead of running it five times. Try this:
for i in range(5):
     a[i,indices[i]]=1

Do tell me if this has a high overhead too as there would most probably be more efficient methods