gpt4 book ai didi

haskell - 对Eta reduce的理解

转载 作者:行者123 更新时间:2023-12-04 23:26:58 25 4
gpt4 key购买 nike

weightDelta 上运行 hlint 时函数不断提示 Eta 减小。我读了另一个相关的 Eta 减少 question ,但我似乎无法将理解转移到这种情况下。

module StackQuestion where

import qualified Data.Vector as V

type Weights = V.Vector Double
type LearningRate = Double

weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights
weightDelta n r y ws = V.map update ws
where update w = diff * n * w
diff = r - y

我试图“减少”它以指向免费语法的每一个更改都会破坏它。
要进行的更改在哪里,是否有任何直觉或技巧可以避免将来出现 eta 减少建议?

最佳答案

你不会很容易地把它变成无点语法,但你可以立即做的只是 η-reduce ws离开。

weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights
weightDelta n r y = V.map update
where update w = diff * n * w
diff = r - y

你也可以做类似的事情
        where update = (δ *)
δ = n * (r - y)

但这是值得商榷的。

关于haskell - 对Eta reduce的理解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11381812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com