[英]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. 我正在考虑更改hnn包以支持网络中每个节点的不同激活功能。
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. 其中
N
是节点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. 我需要帮助(因为我在包源代码中丢失)以找到从列表中应用
Nth
activations
函数的方法。
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 编辑:我尝试使用
tick
(来自文档)和使用zip
函数的StateT
方法,每个步骤都给出多次执行,因此最终结果会出错
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.
所以实际上没什么可做的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.