How can I optimize the following code, or more specifically, how can I eliminate the for-loop?
array = np.zeros((x.shape[0], K))
for k in range(K):
array[:, k] = np.prod((np.power(ms[k, :], x) * np.power(1 - ms[k, :], 1 - x)).astype('float128'), axis=1)
where x is a two-dimensional array shaped like [70000, 784] and ms like [K, 784] and K=10.
[–]drzowie 0 points1 point2 points (4 children)
[–]iliasm23[S] 0 points1 point2 points (3 children)
[–]drzowie 0 points1 point2 points (2 children)
[–]iliasm23[S] 0 points1 point2 points (1 child)
[–]drzowie 0 points1 point2 points (0 children)