My program is using non scalar backward
and self mini batch implementation like bellow(because each data has huge size)
for i in range(len(batch_list)):

     output = network(batch_list[i])   #non scalar output
     grad = grad_fn(output, teacher[i])  #calc non scalar grad
     torch.autograd.backward([output],[grad])  #non scalar backwarding

optimizer.step()
optimizer.zero_grad() 

It seems my Network isn’t training correctly.
I think the section I cropped has a problem.
(Note that, for the simplicity the code isn’t original.
but it has a essence of my flowchart.)
Are there some weird point ?
In self implementation, how minibatch work?
I think i should divide gradient.