[英]Haskell - Passing each element of array with another parameter to function
I'm pretty new to Haskell, and have been trying to solve this for a while. 我对Haskell来说还很陌生,并且已经尝试解决了一段时间。
I have a function: 我有一个功能:
sumNodeError :: Node -> Layer -> Double
sumNodeError node childLayer = foldl (+) 0 (listProduct (weights node) (errors childLayer))
calculateNodeError :: Node -> Layer -> Double
calculateNodeError node childLayer = (sumNodeError node childLayer) * (value node) * (1.0 - (value node))
-- problem is in this function
calculateErrors :: Layer -> Layer -> Layer
calculateErrors layer childLayer = Layer (nodes layer)
(map calculateNodeError (nodes layer) childLayer ) -- problem, need to map each of the nodes in the layer, and the childLayer to calculateNodeError
(teacherSignals layer)
(learningRate layer)
I am needing to pass each (nodes layer)
and the childLayer
to function calculateNodeError
我需要通过每个
(nodes layer)
和childLayer
起作用calculateNodeError
The rest of the code (which isn't much) can be found here if you need: https://github.com/kennycason/haskell_nn/ 如果需要,可以在这里找到其余的代码(不是很多): https : //github.com/kennycason/haskell_nn/
Thanks a lot. 非常感谢。
干得好
(map (\n -> calculateNodeError n childLayer) (nodes layer) )
这是另一种解决方案。
map ((flip calculateNodeError) childLayer) (nodes layer)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.