enj*_*ife 4 haskell types ghc pointfree
当在weightDelta
函数上运行hlint时,一直在暗示Eta减少.我读了另一个相关的Eta reduce 问题,但我似乎无法将理解转移到这个案例中.
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
Run Code Online (Sandbox Code Playgroud)
我试图"减少"它以指向免费语法的每一个改变都会破坏它.哪里有变化,是否有任何直觉或伎俩可以避免将来减少eta减少的建议?
你不会轻易地得到无点语法,但你可以立即做的只是η-减少了ws
.
weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights
weightDelta n r y = V.map update
where update w = diff * n * w
diff = r - y
Run Code Online (Sandbox Code Playgroud)
你也可以这样做
where update = (? *)
? = n * (r - y)
Run Code Online (Sandbox Code Playgroud)
但这是值得商榷的.
归档时间: |
|
查看次数: |
1141 次 |
最近记录: |