The following protocols are available globally.

  • 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 VectorNumeric
  • A type that represents an unranked vector space. Values of this type are elements in this vector space and have a dynamic shape.

    Declaration

    public protocol ShapedVectorNumeric : VectorNumeric
  • A type that mathematically represents a differentiable manifold whose tangent spaces are finite-dimensional.

    Declaration

    public protocol Differentiable
  • Declaration

    public protocol TensorFlowScalar : _TensorFlowDataTypeCompatible
  • 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
      where Self.RawSignificand: FixedWidthInteger,
            Self == Self.TangentVector,
            Self == Self.CotangentVector,
            Self == Self.AllDifferentiableVariables
  • A type whose values provides custom key paths to properties or elements.

    Declaration

    public protocol KeyPathIterable : _KeyPathIterableBase
  • 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 call method for mapping inputs to outputs.

    Declaration

    public protocol Layer: Differentiable & KeyPathIterable
        where AllDifferentiableVariables: KeyPathIterable
  • A recurrent neural network cell.

    Declaration

    public protocol RNNCell: Layer where Input == RNNCellInput<TimeStepInput, State>,
                                         Output == RNNCellOutput<TimeStepOutput, State>
  • 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 machine learning optimizer.

    Optimizers apply an optimization algorithm to update the differentiable variables of a machine learning model.

    Declaration

    public protocol Optimizer
  • 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 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.

    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