In the Optional Lab 02 of Course 1 Week 3, does anyone know how the function g(z)
is evaluated when z
is a vector of scalar values, where each scalar component value is computed from using the linear regression model with a previously unknown vector of input feature values \vec x^{(i)}, for some i
, where i = 1 to m
?
Hi @ai_is_cool
The function g(z)
is applied to the output of the linear regression model z = w⋅x + b. When z
is a vector (as in this case), the sigmoid function is applied element-wise to each value in the vector. So, every computed z[i]
gets transformed into a probability between 0 and 1.
Hope it helps!
Thanks @Alireza_Saei for your reply.
Yes that helps although I was thinking more mathematically how e^{-z} is evaluated when z
is a vector of scalar values.
Do you know if there is even such an operation mathematically?
Mathematically this operation doesn’t exist unless you consider a matrix with a single column and more than 1 row.
It would be interesting to create an array z
in Python using the NumPy module and try passing it to the function math.exp(…)
.
Hi @ai_is_cool ,
For deep learning, the function np.exp() is preferred as it deals with array like input.
There are lots of math library functions that work element-wise on all values in a scalar, vector, or matrix.
Do you mean Python library modules?