12

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

0

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

4 Comments

So, would it be possible then to do: zipWith activations $! zipVectorWith (-) (weights <> prefixed) thresh instead of line 93 ?
BUT! computeStep in my opinion does not have ALL the data. Therefore list sizes would be different
Another option might be to use StateT to add the index counter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.