function SoftMax()

function SoftMax()

Postby Antonio Linares » Tue May 14, 2024 7:02 pm

la función SoftMax() hace que la suma de todos los valores sea 1

Esto se conoce como "normalización" o "estandarización" de los valores

Code: Select all  Expand view
function Main()

   local aValues := { 1, 2, 3 }

   ? SoftMax( aValues )
   
   ? aValues[ 1 ] + aValues[ 2 ] + aValues[ 3 ]   // { 0.09, 0.24, 0.67 } --> 1

return nil

FUNCTION Softmax( aValues )

   LOCAL n, nSum := 0

   FOR n := 1 TO Len( aValues )
      nSum += Exp( aValues[ n ] )
   NEXT

   FOR n := 1 TO Len( aValues )
      aValues[ n ] := Exp( aValues[ n ] ) / nSum
   NEXT

RETURN aValues
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41420
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 2 guests