# Sigmoid Function not working as expected

I want to write the below function in computation layer
SIGMOID Function:
y = 1 / ( 1 + e^( - x))

The code i wrote is:
function(“f”): simpleFunction(“1/(1+2.7)^(-x)”)

The output is always showing undefined , Not sure what is wrong.

Expected Output range is [0 to 1]

Can anyone help me solve this

Yeah, it’s not properly formatted in latex. The easiest way is to type the function in the calculator, copy it, and then paste it into CL. All the formatting will be done perfectly that way.

2 Likes

Thanks It worked!

I have one more query, It always rounds off my output to 1. Is there a way I can make it to display upto 2 decimal places.

finalVal = “0.996”
number(“p_{out}”): numericValue(finalVal)

This gives out 1 instead of 0.996

You might have more luck defining it as a function and using the evaluateAt method.

f = simpleFunction(latex string)
Val = f.evaluateAt(input value)

I’m not sure about rounding. What you are trying to do may be more easily accomplished inside a graph component. You can definitely use the round(value, places) function in the graph. You can pass inputs into the graph by sinking a number into a variable and then you can pull outputs from the graph using the variables as sources. If you don’t want the graph to be seen you can just set hidden to true in its CL.

If you want an example let me know.

1 Like

Thanks for the response, It got fixed!

As you mentioned, I simply used round(value,decimalplaces) around the value. Thanks for the support

1 Like