instinct-0.1.0: AI/Instinct/Activation.hs
-- |
-- Module: AI.Instinct.Activation
-- Copyright: (c) 2011 Ertugrul Soeylemez
-- License: BSD3
-- Maintainer: Ertugrul Soeylemez <es@ertes.de>
--
-- Activation functions.
module AI.Instinct.Activation
( -- * Type
Activation(..),
actFunc,
actDeriv
)
where
-- | Activation functions.
data Activation
= LogisticAct -- ^ Logistic activation.
deriving (Read, Show)
-- | Apply an activation function.
actFunc :: Activation -> Double -> Double
actFunc LogisticAct = logistic
-- | Apply the derivative of an activation function.
actDeriv :: Activation -> Double -> Double
actDeriv LogisticAct x = let lx = logistic x in lx * (1 - lx)
-- | This is the logistic activation function.
logistic :: Double -> Double
logistic x = 1 / (1 + exp (-x))