I think based on your error, euclidean distance will return a float number for any two nd matrix. So de+= is always a float number. std cannot be computed for a single float number.

Could you please provide what library you are using for calculating euclidean distance?

But typically, you can calculate it using torch.dist(output, input, 2). Here is the documentation.

I need to do what i did, for other things in the program. What i want, is just to calculate the mean of the values given by variable: de
I know that it is very easy, but can you explain me, how can i do that?

With this shape of inputs, de only can be a single float number. Mean of a single number is itself.
By below code

You are adding 768 distances which will result in a single number. Are you looking for having a list of 768 separate distances then calculating mean for them?

This loop is always printing the distance values, and then end, when finished iterating all data.

ne=ne.detach().cpu().numpy()
naa=naa.detach().cpu().numpy()
de=0
for ne, naa in zip(ne, naa):
de+=distance.euclidean(naa,ne)
print(de/size_batch)

I want to calculate the mean of all printed values, it is clear now what i want to do?
The print, prints values like: 3.21412
3.124124
3.112412
3.42121
And i want to calculate the mean of all this printed values.