I am trying to put all my model’s output in an array, though I am using it in eval mode,
computing the output with torch.no_grad(): and detaching it the array is showing grad_fn=<SelectBackward>
My code
m.eval() # m is my model
for vec,ind in loaderx:
with torch.no_grad():
opp,_,_ = m(vec)
opp = opp.detach().cpu()
for i in range(ind.shape[0]):
ar[i] = torch.cat((torch.tensor([ind[i]]),opp[i]),dim =0)
break
when I try to output the array where my outputs are ar[0][0] #shown only one element since its a big array
output → tensor(3239., grad_fn=<SelectBackward>)
m.eval()
for vec,ind in loaderx:
with torch.no_grad():
opp,_,_ = m(vec)
for i in range(ind.shape[0]):
ans = torch.cat((torch.tensor([ind[i]]),opp[i]),dim =0)
ar[ind[i]] = ans
But can you solve another query, detach() should have been cut it in the computational graph then why it didn’t work?