Does the order of with torch.no_grad(): and model.eval() matter?
Let models be saved in a list model_list.
for m in model_list:
m.eval()
with torch.no_grad():
netout = m(x)
print(netout)
OR
with torch.no_grad():
for m in model_list:
m.eval()
netout = m(x)
print(netout)
In the latter example we avoid multiple calls of with torch.no_grad()
.