Search code examples
c#neural-networkweka

how Weka calculates Sigmoid function c#


I am using weka with my dataset to train a neural network and now I want to use the results (weights and thresholds produced by weka) in my application and implement only the forward pass.

now the problem is that I don't know how exactly weka calculates the sigmoid function, with what conditions etc. In order to use the results produced by weka I really need this information and write the exact same code that is used by weka.

can someone please tell me this? or provide me with a source that explains this thing? I would really appreciate the help.

I hope the question is clear and I need the answer Ungently


Solution

  • From the source:

    if (value < -45) {
      value = 0;
    }
    else if (value > 45) {
      value = 1;
    }
    else {
      value = 1 / (1 + Math.exp(-value));
    }  
    return value;
    

    Pretty simple sigmoid with a clamp using the logistic function.

    That said, you're very likely not going to be able to replicate the results exactly with just that - there a great many details involved and you'll have to read the source and understand them all.