Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mapping function from list to data

Tags:

haskell

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

like image 982
Boris Mocialov Avatar asked May 30 '15 03:05

Boris Mocialov


1 Answers

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.

like image 166
sdx23 Avatar answered Oct 22 '22 03:10

sdx23