FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Utilities / Utilidades function softMax()
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
function softMax()
Posted: Fri Aug 21, 2020 10:24 PM
function softMax() returns an array of probabilities from an array of numeric values

https://deepai.org/machine-learning-glossary-and-terms/softmax-layer

https://github.com/ujhuyz0110/notes/blob/master/softmax_gradient.pdf

Code (fw): Select all Collapse
function Main()

   local aValues := { 8, 5, 1 } 
   local aResults := softMax( aValues )
   local nVal

   for each nVal in aResults
      ? nVal
   next

return nil

function softMax( aValues )

   local nSum := 0, nVal, aResults := Array( Len( aValues ) )

   for each nVal in aValues
      nSum += exp( nVal )
   next

   for each nVal in aValues
      aResults[ nVal:__enumIndex ] = exp( nVal ) / nSum
   next

return aResults


regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion