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); }