0
function g = sigmoid(z)

%SIGMOID Compute sigmoid function
%J = SIGMOID(z) computes the sigmoid of z.

g = 1.0 ./ (1.0 + exp(-z));

end

I'm going through the Andrew Ng Coursera course. I doubt that how exp(-z) is computed directly while z is a matrix?

Avi
  • 103
  • 3
akib
  • 11
  • 1

1 Answers1

2

In many languages and libraries, operations that apply to a scalar can be applied to vectors, matrices and tensors. They're just applied element-wise, and the result is another vector, matrix, etc with each value transformed by that function.

Sean Owen
  • 6,664
  • 6
  • 33
  • 44