HaskellNN-0.1: src/AI/Calculation/NetworkOutput.hs
----------------------------------------------------
-- |
-- Module : AI.Network
-- License : GPL
--
-- Maintainer : Kiet Lam <ktklam9@gmail.com>
--
--
-- This module provides forward propagation
-- to let the user get the output of the neural
-- network given an input vector
--
--
----------------------------------------------------
module AI.Calculation.NetworkOutput (
networkOutput
) where
import Numeric.Container
import AI.Network
-- | Forward propagate to get the network's output
networkOutput :: Network -- ^ The neural network of interest
-> Vector Double -- ^ The input vector
-> Vector Double -- ^ The output vector of the output neurons
networkOutput nn inVec =
let activF = toActivation nn
ws = toWeightMatrices nn
fBias = \v -> fromList $ 1.0:(toList v :: [Double])
in
foldl (\as w -> mapVector activF ((fBias as) `vXm` w)) inVec ws