You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Math/SoftMax.cs

23 lines
553 B

using System;
namespace ZeroLevel.Services.Mathematic
{
public static class SoftMax
{
public static double[] Compute(double[] vector)
{
double sum = 0;
for (int i = 0; i < vector.Length; i++)
{
sum += Math.Exp(vector[i]);
}
double[] result = new double[vector.Length];
for (int i = 0; i < vector.Length; i++)
{
result[i] = Math.Exp(vector[i]) / sum;
}
return result;
}
}
}

Powered by TurnKey Linux.