mirror of https://github.com/ogoun/Zero.git
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.
23 lines
555 B
23 lines
555 B
using System;
|
|
|
|
namespace ZeroLevel.Services.Mathemathics
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|