public protocol Differentiable

A type that mathematically represents a differentiable manifold whose tangent spaces are finite-dimensional.

  • A type representing a differentiable value’s derivatives.

    Mathematically, this is equivalent to the tangent bundle of the differentiable manifold represented by the differentiable type.

    Declaration

    associatedtype TangentVector : AdditiveArithmetic, Differentiable where Self.TangentVector == Self.TangentVector.TangentVector
  • move(along:)

    Default implementation

    Moves self along the given direction. In Riemannian geometry, this is equivalent to exponential map, which moves self on the geodesic surface along the given tangent vector.

    Default Implementation

    Declaration

    mutating func move(along direction: TangentVector)
  • zeroTangentVector

    Default implementation

    A tangent vector such that move(along: zeroTangentVector) will not modify self.

    Note

    zeroTangentVector can be TangentVector.zero in most cases, but types whose tangent vectors depend on instance properties of self need to provide a different implementation. For example, the tangent vector of an Array depends on the array’s count.

    Default Implementation

    Declaration

    @available(*, deprecated, message: "`zeroTangentVector` derivation has not been implemented; do not use this property")
    var zeroTangentVector: TangentVector { get }
  • Declaration

    typealias AllDifferentiableVariables = Self
  • Declaration

    @differentiable
    func withRecomputationInPullbacks<Result : Differentiable>(
      _ body: @escaping @differentiable (Self) -> Result
    ) -> Result
  • sequenced(through:_:)

    Extension method

    Returns the output computed by applying a sequence of layers to the previous layer’s output, except that the first layer’s input is self.

    Declaration

    @differentiable
    func sequenced<L1: Layer, L2: Layer>(through l1: L1, _ l2: L2) -> L2.Output
        where L1.Input == Self, L1.Output == L2.Input

    Parameters

    l1

    The first layer.

    l2

    The second layer.

    Return Value

    The final layer’s output after sequential application.

  • sequenced(through:_:_:)

    Extension method

    Returns the output computed by applying a sequence of layers to the previous layer’s output, except that the first layer’s input is self.

    Declaration

    @differentiable
    func sequenced<L1: Layer, L2: Layer, L3: Layer>(through l1: L1, _ l2: L2, _ l3: L3) -> L3.Output
        where L1.Input == Self, L1.Output == L2.Input, L2.Output == L3.Input

    Parameters

    l1

    The first layer.

    l2

    The second layer.

    l3

    The third layer.

    Return Value

    The final layer’s output after sequential application.

  • sequenced(through:_:_:_:)

    Extension method

    Returns the output computed by applying a sequence of layers to the previous layer’s output, except that the first layer’s input is self.

    Declaration

    @differentiable
    func sequenced<L1: Layer, L2: Layer, L3: Layer, L4: Layer>(
        through l1: L1, _ l2: L2, _ l3: L3, _ l4: L4
    ) -> L4.Output
        where L1.Input == Self, L1.Output == L2.Input, L2.Output == L3.Input,
              L3.Output == L4.Input

    Parameters

    l1

    The first layer.

    l2

    The second layer.

    l3

    The third layer.

    l4

    The fourth layer.

    Return Value

    The final layer’s output after sequential application.

  • sequenced(through:_:_:_:_:)

    Extension method

    Returns the output computed by applying a sequence of layers to the previous layer’s output, except that the first layer’s input is self.

    Declaration

    @differentiable
    func sequenced<L1: Layer, L2: Layer, L3: Layer, L4: Layer, L5: Layer>(
        through l1: L1, _ l2: L2, _ l3: L3, _ l4: L4, _ l5: L5
    ) -> L5.Output
        where L1.Input == Self, L1.Output == L2.Input, L2.Output == L3.Input, L3.Output == L4.Input,
              L4.Output == L5.Input

    Parameters

    l1

    The first layer.

    l2

    The second layer.

    l3

    The third layer.

    l4

    The third layer.

    l5

    The fifth layer.

    Return Value

    The final layer’s output after sequential application.

  • Returns the output computed by applying a sequence of layers to the previous layer’s output, except that the first layer’s input is self.

    Declaration

    @differentiable
    func sequenced<L1: Layer, L2: Layer, L3: Layer, L4: Layer, L5: Layer, L6: Layer>(
        through l1: L1, _ l2: L2, _ l3: L3, _ l4: L4, _ l5: L5, _ l6: L6
    ) -> L6.Output
        where L1.Input == Self, L1.Output == L2.Input, L2.Output == L3.Input, L3.Output == L4.Input,
              L4.Output == L5.Input, L5.Output == L6.Input

    Parameters

    l1

    The first layer.

    l2

    The second layer.

    l3

    The third layer.

    l4

    The third layer.

    l5

    The fifth layer.

    l6

    The sixth layer.

    Return Value

    The final layer’s output after sequential application.