TechNewsHeaven {{source.name}}




First-Class Automatic Differentiation in Swift: A Manifesto
2018-10-22T04:08:22.9722306Z - 262588213843476 / Hacker News
In the context of Swift, differentiating a function (Float) -> Float produces (Float) -> Float . , so the derivative of such a function has type (Float, Float) -> (Float, Float) . let g = f as @autodiff ( Float ) -> Float func takesFunc ( _ someFunc : @autodiff ( Float ) -> Float ) { # derivatives (someFunc) ... } // At the callsite of `takesFunc(_:)`, `f` gets implcitly differentiated to become // `@autodiff (Float) -> Float`. let linear : @autodiff (linear) ( Float ) -> Float = ... let bidir : @autodiff ( Float ) -> Float = ... let const : @autodiff (constant) ( Float ) -> Float = ... func foo ( _ : @autodiff (reverse) ( Float ) -> Float ) { ... } foo (linear) // Okay! After deriving conformances to VectorNumeric :struct Parameters : VectorNumeric { var a : Vector < Float > var b : Float // derived: typealias Scalar = Float // derived: struct Shape { var a : Vector < Float > .

Your favorite news


Popular news




Recommended news