The following protocols are available globally.

  • Declaration

    public protocol TensorFlowScalar : _TensorFlowDataTypeCompatible
  • Declaration

    public protocol TensorRangeExpression
  • An integer data type that represents integer types which can be used as tensor indices in TensorFlow.

    Declaration

    public protocol TensorFlowIndex : BinaryInteger, TensorFlowScalar
  • A floating-point data type that conforms to Differentiable and is compatible with TensorFlow.

    Note

    Tensor conditionally conforms to Differentiable when the Scalar associated type conforms TensorFlowFloatingPoint.

    Declaration

    public protocol TensorFlowFloatingPoint:
        TensorFlowScalar & BinaryFloatingPoint & Differentiable & ElementaryFunctions
        where Self.RawSignificand: FixedWidthInteger,
              Self == Self.TangentVector
  • A type that mathematically represents a differentiable manifold whose tangent spaces are finite-dimensional.

    Declaration

    public protocol Differentiable
  • A type with values that support pointwise multiplication.

    Declaration

    public protocol PointwiseMultiplicative : AdditiveArithmetic
  • A type that represents an unranked vector space. Values of this type are elements in this vector space and have either no shape or a static shape.

    Declaration

    public protocol VectorProtocol : AdditiveArithmetic
  • A type that is differentiable in the Euclidean space. The type may represent a vector space, or consist of a vector space and some other non-differentiable component.

    Mathematically, this represents a product manifold that consists of a differentiable vector space and some arbitrary manifold, where the tangent bundle of the entire product manifold is equal to the vector space component.

    This abstraction is useful for representing common differentiable data structures that contain both differentiable vector properties and other stored properties that do not have a derivative, e.g.

    struct Perceptron: @memberwise EuclideanDifferentiable {
        var weight: SIMD16<Float>
        var bias: Float
        @noDerivative var useBias: Bool
    }
    

    Note

    Conform a type to EuclideanDifferentiable if it is differentiable only with respect to its vector space component and when its TangentVector is equal to its vector space component.

    Declaration

    public protocol EuclideanDifferentiable : Differentiable
  • A type whose values provides custom key paths to properties or elements.

    Declaration

    public protocol KeyPathIterable : _KeyPathIterableBase
  • Declaration

    public protocol Module: EuclideanDifferentiable, KeyPathIterable
        where TangentVector: VectorProtocol & ElementaryFunctions &
                             PointwiseMultiplicative & KeyPathIterable
  • A neural network layer.

    Types that conform to Layer represent functions that map inputs to outputs. They may have an internal state represented by parameters, such as weight tensors.

    Layer instances define a differentiable callAsFunction(_:) method for mapping inputs to outputs.

    Declaration

    public protocol Layer : Module where Self.Input : Differentiable
  • A parameterless neural network layer.

    The TangentVector of parameterless layers is always EmptyTangentVector.

    Declaration

    public protocol ParameterlessLayer : Layer where Self.TangentVector == EmptyTangentVector
  • A type that can be initialized from a numpy.ndarray instance represented as a PythonObject.

    Declaration

    public protocol ConvertibleFromNumpyArray
  • A type that is bitwise compatible with one or more NumPy scalar types.

    Declaration

    public protocol NumpyScalarCompatible
  • A numerical optimizer.

    Optimizers apply an optimization algorithm to update the differentiable models.

    Declaration

    public protocol Optimizer
  • A type whose values can be converted to a PythonObject.

    Declaration

    public protocol PythonConvertible
  • A type that can be initialized from a PythonObject.

    Declaration

    public protocol ConvertibleFromPython
  • A type that provides seedable deterministic pseudo-random data.

    A SeedableRandomNumberGenerator can be used anywhere where a RandomNumberGenerator would be used. It is useful when the pseudo-random data needs to be reproducible across runs.

    Conforming to the SeedableRandomNumberGenerator Protocol

    To make a custom type conform to the SeedableRandomNumberGenerator protocol, implement the init(seed: [UInt8]) initializer, as well as the requirements for RandomNumberGenerator. The values returned by next() must form a deterministic sequence that depends only on the seed provided upon initialization.

    Declaration

    public protocol SeedableRandomNumberGenerator : RandomNumberGenerator
  • Declaration

    public protocol RandomDistribution
  • A recurrent neural network cell.

    Declaration

    public protocol RNNCell: Layer
        where Input == RNNCellInput<TimeStepInput, State>, 
              Output == RNNCellOutput<TimeStepOutput, State>
  • Declaration

    public protocol TensorOperation
  • Declaration

    public protocol TFTensorOperation : TensorOperation
  • Special protocol for calling tensorflow operations that take heterogeneous arrays as input.

    Declaration

    public protocol AnyTensor
  • A protocol representing types that can be mapped to Array<CTensorHandle>.

    This protocol is defined separately from TensorGroup in order for the number of tensors to be determined at runtime. For example, [Tensor<Float>] may have an unknown number of elements at compile time.

    This protocol can be derived automatically for structs whose stored properties all conform to the TensorGroup protocol. It cannot be derived automatically for structs whose properties all conform to TensorArrayProtocol due to the constructor requirement (i.e., in such cases it would be impossible to know how to break down count among the stored properties).

    Declaration

    public protocol TensorArrayProtocol
  • A protocol representing types that can be mapped to and from Array<CTensorHandle>.

    When a TensorGroup is used as an argument to a tensor operation, it is passed as an argument list whose elements are the tensor fields of the type.

    When a TensorGroup is returned as a result of a tensor operation, it is initialized with its tensor fields set to the tensor operation’s tensor results.

    Declaration

    public protocol TensorGroup : TensorArrayProtocol
  • Declaration

    public protocol TensorProtocol