Is there a better way to compute this using numpy

Viewed 39

Is there a numpy function that could do this without looping like that?

for i in range(784):
    for j in range(128):
        w[i, j] = x[i] * d[j]
1 Answers

I would try this

x = np.expand_dims(x,1)
y = np.expand_dims(y,0)

result = np.matmul(x,y)
Related