Boris Mocialov
Boris Mocialov

Reputation: 3489

mapping function from list to data

I am looking at changing the hnn package to support different activation functions for every node in a network.

In particular, this line and this line use specific function (activation), but I am trying to extended that to support something like:

evalNet n@(Network{..}) inputs activations = do
    s <- foldM (\x -> computeStepM n x (activations!!N)) state inputsV

where N is the node id/index.

Currently I am a stage where I have my list of activation functions of the same length as amount of nodes in the network.

I need help (as I am lost in the package source code) to find a way to apply Nth activations function from the list.

EDIT: I have tried StateT approach using tick (from documentation) and using zip function, both give multiple executions per every step, so the final result becomes wrong

Upvotes: 12

Views: 402

Answers (1)

sdx23
sdx23

Reputation: 168

For the map you may want something like

as = [(+1),(*2),(+(-3))]
xs = [4,5,6]
main = print $ zipWith ($) as xs

The fold is more complicated but can be done with using the same idea: Zip the inputs with according activation functions and change the function-folded-over to use the values of the incoming tuples.

However, I doubt you really need/want to change the fold. If I'm not mistaken the fold should just pass on the activation-functions list. So there's actually nothing to do.

Upvotes: 3

Related Questions