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

Thanks!

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

Thanks!

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 - `np.dot`

. You can say that, it is equivalent to `w[0]*x[0] + w[1]*x[1] + … + w[n-1]*x[n-1]`

, but `np.dot`

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]`

.

Cheers,

Raymond

Yes, w and x are vectors.

Thank you!

1 Like