I need to implement an algorithm. But it takes a lot of time to compute and I need to make it as fast as possible.
Right now I have two numpy arrays:
Array A -> 2000 vectors of 512 elements,
Array B -> 1000 vectors of 512 elements.
I need to calculate every single distance between the vectors from Array A and Array B. Right now, I take 1 vector from array A, and calculate it's distances to all vectors in Array B as follows:
np.sum(np.abs(B-A[0])**2,axis=-1)**(0.5)
But using this I have to loop for 2000 cycles and it takes a lot of time.
Any alternatives?