I have a list of ND arrays(vectors), each vector has a (1,300)
shape.
My goal is to find duplicate vectors inside a list, to sum them and then divide them by the size of a list, the result value(a vector) will replace the duplicate vector.
For example, a
is a list of ND arrays, a = [[2,3,1],[5,65,-1],[2,3,1]]
, then the first and the last element are duplicates.
their sum
would be :[4,6,2]
,
which will be divided by the size of a list of vectors, size = 3
.
Output: a = [[4/3,6/3,2/3],[5,65,-1],[4/3,6/3,2/3]]
I have tried to use a Counter
but it doesn't work for ndarrays.
What is the Numpy way? Thanks.