How is wx implemented? Is it also a vectorised implementation or is wx evaluated as w[0]*x[0] + w[1]*x[1] + … + w[n-1]*x[n-1]?


Hi @mvrbiguv , the vectorization for wx using numpy as np would be:

wx =, x)

Hello @mvrbiguv,

Are w and x two vectors? If they are vectors, then in terms of Python code, it should be implemented in the way @Nydia said, because in Python code, we can’t just stick two variables together, and instead, we need to supply the function - You can say that, it is equivalent to w[0]*x[0] + w[1]*x[1] + … + w[n-1]*x[n-1], but is a vectorized process, and it is more efficient that explicitly programming Python to do w[0]*x[0] + w[1]*x[1] + … + w[n-1]*x[n-1].


Yes, w and x are vectors.

Thank you!

1 Like