Reputation: 19
I wanted to add two 5 X 1 column vector. But I am getting error: Invalid syntax
def sumg():
w = np.ones((5,1))
s = 1
g=0
b = np.random.rand(5,1)
g = b + np.multiply(s,w)
return(g)
I expect the output to return b+s*w
Upvotes: 0
Views: 8001
Reputation: 2290
You should import numpy and indent the return statement correctly. like
import numpy as np
def sumg():
w = np.ones((5,1))
s = 1
g=0
b = np.random.rand(5,1)
g = b + np.multiply(s,w)
return(g)
return(g) should start where g start from .Hope it will help.
Upvotes: 1