2

I'm attempting to implement Logistic regression in .net using MathNumerics Linear Algebra libraries. I need to implement the following equation and am unsure of how to accomplish raising e by a matrix.

1.0 ./ (1.0 + E .^ (-1 .* Z))

where Z is a matrix and E is the mathematical constant e.

So the problematic section of code is E .^ Z

Guy Coder
  • 24,501
  • 8
  • 71
  • 136
David Crook
  • 2,722
  • 3
  • 23
  • 49

1 Answers1

2
let sigmoid (z : Matrix<double>) : Matrix<double> =
        z.Map (fun x -> 1.0 / (1.0 + exp (0.0 - x)))
Guy Coder
  • 24,501
  • 8
  • 71
  • 136