Python doubt in mean

a=[]
for ne, naa in zip(ne, naa): 
   de+=distance.euclidean(naa,ne)
a.append(de/size_batch)
print(*a, sep = ", ")

I wanted to put all data inside the array, and print whats inside it.
I think the array is overwriting, and its stuck on the first position. How can i store all values in this array?

I tried this to:

v=0
a.insert(v,de/size_batch)
++v

And i get the same result.
The output is just a value and not all the values.
Can someone help me?

The approach should work.
Could you check the size of ne and naa?
zip will just use the smaller of both lengths. If one of these tensors only contains a single sample, you would only use a single iteration.

Ah sorry, I missed the errors.

You are currently overwriting ne and naa in the loop, so use other variable names for the single elements and also move the a.append call inside the loop:

for ne_, naa_ in zip(ne, naa): 
   de+=distance.euclidean(naa_,ne_)
   a.append(de/size_batch)
1 Like

Thank you :slight_smile: