Should I evaluate data per each or at once?

Hello, everyone
I have one question which I cannot solve

In PyTorch
when evaluating (not training),
codes are just like as below

output = np.full(len(testdata), -0.5)

model.eval()
with torch.no_grad():
for ii in range(len(testdata)):
data = torch.Tensor( testdata.iloc[…
output[ii] = model(data)

The above source code evaluates data per each sample
which is very very slow

My question is:
May I evaluate the testdata wholely at once?
That is,

model.eval()
with torch.no_grad():
data = … whole test data at once
output = copy.deepcopy(model(data)) //something like this

Can I do this? (which looks very fast)

Thank you in advance

Hi, if your data fits into RAM to test it all at once then you can certainly do this.
The reason why we use batches normally is exactly because we cannot load all the data into RAM.

Hope this helps!

Hello, janhenr.
Thank you for your answer.
So is there no difference between the two results (at once and per sample)??

Have a nice day