I have tried this
Public Function sigmoid(ByRef x As Integer, ByVal y As Integer) As Integer
y = 1 / (1 + Math.Exp(-x))
y3 = (x1 * w13 + x2 * w23 - seta3).sigmoid
I see several things I would change for the Sigmoid function:
Public Module module1 <System.Runtime.CompilerServices.Extension()> _ Public Function Sigmoid(ByRef x As Integer) As Double Return 1 / (1 + Math.Exp(-x)) End Function <System.Runtime.CompilerServices.Extension()> _ Public Function Sigmoid(ByRef x As Double) As Double Return 1 / (1 + Math.Exp(-x)) End Function End Module
Public. Otherwise, you might not see the method available when you need it.
Return Nothinghad no meaning, as it directly followed another return statement.
yinput to the function was never used, so don't ask for it.
Double, rather than an
Integerfor the return type. It's unlikely that a division expression with a
1for the first term will ever result in an workable Integer.
y3variable, and that in turn makes we wonder how many other values here should really be doubles, hence the overloaded method.
Now you can call it like this:
y3 = (x1 * w13 + x2 * w23 - seta3).Sigmoid()
Note that in VB.Net, it's a best practice to always use the
() notation when calling a function. This is not required, but still a good habit to have. This is a change from older VB6/VBA/VBScript code, where using parentheses had undesirable side effects in some cases.