This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |