mxnet-nn-0.0.1.3: Train a neural network with MXNet in Haskell.

Safe HaskellNone
LanguageHaskell2010

MXNet.NN

Synopsis

Documentation

data Parameter a Source #

A parameter is two NDArray to back a Symbol

Constructors

Parameter 

Instances

(Pretty a, DType a) => Show (Parameter a) Source # 

data Config a Source #

For every symbol in the neural network, it can be placeholder or a variable. therefore, a Config is to specify the shape of the placeholder and the method to initialize the variables.

Note that it is not right to specify a symbol as both placeholder and initializer, although it is tolerated and such a symbol is considered as a variable.

Note that any symbol not specified will be initialized with the _cfg_default_initializer.

data Session a Source #

Session is all the Parameters and a Context type Session a = (M.HashMap String (Parameter a), Context)

Constructors

Session 

type Initializer a = Context -> [Int] -> IO (NDArray a) Source #

Initializer is about how to create a NDArray from a given shape.

Usually, it can be a wrapper of MXNet operators, such as random_uniform, random_normal, random_gamma, etc..

type TrainM a m = StateT (Session a) m Source #

TrainM is a StateT monad

train :: (DType a, Monad m) => Session a -> TrainM a m r -> m r Source #

Execute the TrainM monad

inferShape :: DType a => Symbol a -> HashMap String (NDArray a) -> IO (HashMap String [Int]) Source #

infer the shapes of all the symbols in a symbolic neural network

initialize :: DType a => Symbol a -> Config a -> IO (Session a) Source #

initialize all parameters

fit :: (DType a, MonadIO m, MonadThrow m, Optimizer opt, OptArgsCst opt g) => opt a g -> Symbol a -> HashMap String (NDArray a) -> TrainM a m () Source #

single step train. Must provide all the placeholders.

fitAndEval :: (DType a, MonadIO m, MonadThrow m, Optimizer opt, OptArgsCst opt g, EvalMetricMethod mth) => opt a g -> Symbol a -> HashMap String (NDArray a) -> Metric a mth -> TrainM a m () Source #

single step train. Must provide all the placeholders. After fitting, it also update the evaluation metric.

forwardOnly :: (DType a, MonadIO m, MonadThrow m) => Symbol a -> HashMap String (Maybe (NDArray a)) -> TrainM a m [NDArray a] Source #

forward only. Must provide all the placeholders, setting the data to Just xx, and set label to Nothing.

Note that the batch size here can be different from that in the training phase.