【发布时间】:2019-07-27 09:12:59
【问题描述】:
为什么他们只在 for 循环中使用 X 而不是 X 和 Y?为什么我们使用 1, -1 的 reshape?
# implement a loop which computes Euclidean distances between each element in X and Y
# store results in euclidean_distances_vector_l list
X = np.random.uniform( low=lower_boundary, high=upper_boundary, size=(sample_size, n) )
Y = np.random.uniform( low=lower_boundary, high=upper_boundary, size=(sample_size, n) )
for index, x in enumerate(X):
euclidean_distances_vector_l.append(euclidean_distances(x.reshape(1, -1), Y[index].reshape(1, -1)))
【问题讨论】:
标签: python numpy numpy-random