Registration is open for TensorFlow Dev Summit 2020

# Differentiable

``public protocol Differentiable``

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

• ``` TangentVector ```

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:) ```

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.

#### 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`.

#### Declaration

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

#### Declaration

``````func gradient<R: TensorFlowFloatingPoint>(
in f: @differentiable (Self) -> Tensor<R>
) -> TangentVector``````
• ``` valueWithGradient(in:) ``` Extension method

#### Declaration

``````func valueWithGradient<R: TensorFlowFloatingPoint>(
in f: @differentiable (Self) -> Tensor<R>
) -> (value: Tensor<R>, gradient: TangentVector)``````
• ``` gradient(at:in:) ``` Extension method

#### Declaration

``````func gradient<T: Differentiable, R: TensorFlowFloatingPoint>(
at x: T,
in f: @differentiable (Self, T) -> Tensor<R>
) -> (TangentVector, T.TangentVector)``````
• ``` valueWithGradient(at:in:) ``` Extension method

#### Declaration

``````func valueWithGradient<T: Differentiable, R: TensorFlowFloatingPoint>(
at x: T,
in f: @differentiable (Self, T) -> Tensor<R>
) -> (value: Tensor<R>, gradient: (TangentVector, T.TangentVector))``````
• ``` withDerivative(_:) ``` Extension method

#### Declaration

``````@differentiable
func withDerivative(_ body: @escaping (inout TangentVector) -> Void) -> Self``````
• ``` withRecomputationInPullbacks(_:) ``` Extension method

#### Declaration

``````@differentiable
func withRecomputationInPullbacks<Result : Differentiable>(
_ body: @escaping @differentiable (Self) -> Result
) -> Result``````
• ``` valueWithPullback(in:) ``` Extension method

#### Declaration

``````func valueWithPullback<R>(
in f: @differentiable (Self) -> R
) -> (value: R, pullback: (R.TangentVector) -> TangentVector)``````
• ``` pullback(in:) ``` Extension method

#### Declaration

``````func pullback<R>(
in f: @differentiable (Self) -> R
) -> (R.TangentVector) -> TangentVector``````
• ``` gradient(in:) ``` Extension method

#### Declaration

``````func gradient<R>(
in f: @differentiable (Self) -> R
) -> TangentVector
where R : FloatingPoint, R.TangentVector == R``````
• ``` valueWithGradient(in:) ``` Extension method

#### Declaration

``````func valueWithGradient<R>(
in f: @differentiable (Self) -> R
) -> (value: R, gradient: TangentVector)
where R : FloatingPoint, R.TangentVector == R``````
• ``` valueWithPullback(at:in:) ``` Extension method

#### Declaration

``````func valueWithPullback<T, R>(
at x: T, in f: @differentiable (Self, T) -> R
) -> (value: R,
pullback: (R.TangentVector) -> (TangentVector, T.TangentVector))``````
• ``` pullback(at:in:) ``` Extension method

#### Declaration

``````func pullback<T, R>(
at x: T, in f: @differentiable (Self, T) -> R
) -> (R.TangentVector) -> (TangentVector, T.TangentVector)``````
• ``` gradient(at:in:) ``` Extension method

#### Declaration

``````func gradient<T, R>(
at x: T, in f: @differentiable (Self, T) -> R
) -> (TangentVector, T.TangentVector)
where R : FloatingPoint, R.TangentVector == R``````
• ``` valueWithGradient(at:in:) ``` Extension method

#### Declaration

``````func valueWithGradient<T, R>(
at x: T, in f: @differentiable (Self, T) -> R
) -> (value: R, gradient: (TangentVector, T.TangentVector))
where R : FloatingPoint, R.TangentVector == R``````
• ``` 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.

• ``` 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, 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.