This is the first F # line I tried writing, so I apologize because I probably just don't know the right Google keywords to search.
I tried to define a function like this:
let sigmoid x deriv = if deriv then x * (1 - x) else 1 / (1 + System.Math.Exp(-x))
This gives me an error on System.Math.Exp(-x)
:
The type 'float' does not match the type 'int'
I assume that I expected the compiler to make type inference in this function and define x
as a float. What am I missing here?
Here is what I am trying to connect:
let sigmoid x deriv = if deriv then x * (1 - x) else 1 / (1 + System.Math.Exp(-x)) [<EntryPoint>] let main argv = sigmoid 1.0 false |> printfn "%A" 0
source share