Skip to content

Instantly share code, notes, and snippets.

View supix's full-sized avatar

supix supix

View GitHub Profile
@jogleasonjr
jogleasonjr / Softmax.cs
Created October 31, 2017 17:49
C# Softmax
// Simplest C# Softmax example
// Based on the Python example here: https://en.wikipedia.org/wiki/Softmax_function
void Main()
{
var z = new[] { 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0 };
var z_exp = z.Select(Math.Exp);
// [2.72, 7.39, 20.09, 54.6, 2.72, 7.39, 20.09]
var sum_z_exp = z_exp.Sum();