float ThresholdFunction(E_THRESHOLDFUNCTION function, float input, float poise = 1) { switch (function) { case E_THRESHOLDFUNCTION.SIGMOID: return(1.0f / (1 + math.exp(-input))); case E_THRESHOLDFUNCTION.TANH: return(math.tanh(input)); case E_THRESHOLDFUNCTION.ARCTAN: return(math.atan(input)); case E_THRESHOLDFUNCTION.ALGEBRAIC: return(input / (1 + math.abs(input))); case E_THRESHOLDFUNCTION.ALGEBRAICWITHPOISE: input = input * poise; var absInput = math.abs(input); return((math.atan(input) * absInput) / (1 + absInput)); case E_THRESHOLDFUNCTION.NONE: return(input); default: return(input); } }
void ComputeThresholdFunctions(int startIndex) { for (int i = startIndex, length = startIndex + ResultCountPerNetwork, lengthMinusOutputCount = length - PerceptronPerLayer[PerceptronPerLayer.Length - 1]; i < length; ++i) { E_THRESHOLDFUNCTION function = i >= lengthMinusOutputCount ? outputLayerFunction : hiddenLayerFunction; Results[i] = ThresholdFunction(function, Results[i], Poise); } }