I wrote equation
with for loops:
A = np.random.rand(10, 100)
B = np.random.rand(100, 100)
c = np.random.rand(100)
@timeit
def operate_loops(X, W, b):
y1 = 0
y2 = 0
y3 = 0
l1 = 0
l2 = 0
for j in range(np.shape(X)[0]):
for n in range(np.shape(W)[1]):
for m in range(np.shape(W)[0]):
y1=y1+X[j][m] * W[m][n]
y2=y2+y1+b[n]
y3=y3+y2
return y3
Now I want to write this equation as numpy vectorized code, without use of loops. I do first summation
like:
np.sum(x[0,:]*w[:,0])
but I don't have a clue how to other sigma summations without looping