1

我对 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)

我需要传递 each(nodes layer)childLayerto 函数calculateNodeError

如果需要,可以在此处找到其余代码(不多):https ://github.com/kennycason/haskell_nn/

非常感谢。

4

2 回答 2

5

干得好

(map (\n -> calculateNodeError n childLayer) (nodes layer) )
于 2013-06-04T18:36:43.403 回答
2

这是另一个解决方案。

map ((flip calculateNodeError) childLayer) (nodes layer)
于 2013-06-04T19:55:01.477 回答