我对Haskell很新,并且一直试图解决这个问题。
我有一个功能:
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)
我需要将每个(nodes layer)
和childLayer
传递给calculateNodeError
如果您需要,可以在此处找到其余代码(不多):https://github.com/kennycason/haskell_nn/
非常感谢。
答案 0 :(得分:5)
你去吧
(map (\n -> calculateNodeError n childLayer) (nodes layer) )
答案 1 :(得分:2)
这是另一种解决方案。
map ((flip calculateNodeError) childLayer) (nodes layer)