1

1.I just try to calculate the distance between two numpy array

 data_partial_test = data_test[:2000,:]
test_lable = label_test

((data_train_set - data_partial_test)**2).sum(axis=1)
print(data_partial_test.shape)
print(data_train_set.shape)

2.What should I in order to solve this error?

Jay Park
  • 308
  • 1
  • 6
  • 14

1 Answers1

0

I think you want:

dist = ((data_train_set[:,None,:] - data_partial_test)**2).sum(axis=1)

But you are looking at a huge amount of data (245GB).

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
  • well actually data_train_set do have value, could you please tell me why you put None right here? – Jay Park Oct 06 '20 at 04:03
  • This technique is usually called [broadcasting](https://numpy.org/doc/stable/reference/generated/numpy.broadcast.html). – Quang Hoang Oct 06 '20 at 04:05