Accord.Math.Special.LogSumExp C# (CSharp) Method

LogSumExp() private method

private LogSumExp ( this array ) : double
array this
return double
        public static double LogSumExp(this double[] array)
        {
            double sum = Double.NegativeInfinity;
            for (int i = 0; i < array.Length; i++)
                sum = Special.LogSum(array[i], sum);
            return sum;
        }
        #endregion

Usage Example

コード例 #1
0
        public static double[] Softmax(double[] input, double[] result)
        {
            double sum = Special.LogSumExp(input);

            for (int i = 0; i < input.Length; i++)
            {
                result[i] = Math.Exp(input[i] - sum);
            }

            return(result);
        }