• Saves tensors in V2 checkpoint format.

    By default, saves the named tensors in full. If the caller wishes to save specific slices of full tensors, shape_and_slices should be non-empty strings and correspondingly well-formed.

    Declaration

    static func saveV2(
      prefix: StringTensor,
      tensorNames: StringTensor,
      shapeAndSlices: StringTensor,
      tensors: [AnyTensor]
    )

    Parameters

    prefix

    Must have a single element. The prefix of the V2 checkpoint to which we write the tensors.

    tensors

    N tensors to save.

  • Restores tensors from a V2 checkpoint.

    For backward compatibility with the V1 format, this Op currently allows restoring from a V1 checkpoint as well:

    • This Op first attempts to find the V2 index file pointed to by prefix, and if found proceed to read it as a V2 checkpoint;
    • Otherwise the V1 read path is invoked. Relying on this behavior is not recommended, as the ability to fall back to read V1 might be deprecated and eventually removed.

    By default, restores the named tensors in full. If the caller wishes to restore specific slices of stored tensors, shape_and_slices should be non-empty strings and correspondingly well-formed.

    Callers must ensure all the named tensors are indeed stored in the checkpoint.

    • Attr dtypes: shape {N}. The list of expected dtype for the tensors. Must match those stored in the checkpoint.

    • Output tensors: shape {N}. The restored tensors, whose shapes are read from the checkpoint directly.

    Declaration

    static func restoreV2(
      prefix: StringTensor,
      tensorNames: StringTensor,
      shapeAndSlices: StringTensor,
      dtypes: [TensorDataType]
    ) -> [AnyTensor]

    Parameters

    prefix

    Must have a single element. The prefix of a V2 checkpoint.

  • Splits a tensor into numSplit tensors along one dimension.

    Declaration

    static func split<T: TensorFlowScalar>(
      splitDim: Tensor<Int32>,
      value: Tensor<T>,
      numSplit: Int64
    ) -> [Tensor<T>]

    Parameters

    splitDim

    0-D. The dimension along which to split. Must be in the range [-rank(value), rank(value)).

    value

    The tensor to split.

    numSplit

    The number of splits to create.

    Return Value

    Tensors whose shape matches that of value except along axis, where their sizes are value.shape[axis] / numSplit.

  • Splits a tensor into numSplit tensors along one dimension.

    Declaration

    static func splitV<T: TensorFlowScalar, Tlen: BinaryInteger & TensorFlowScalar>(
      value: Tensor<T>,
      sizeSplits: Tensor<Tlen>,
      splitDim: Tensor<Int32>,
      numSplit: Int64
    ) -> [Tensor<T>]

    Parameters

    value

    The tensor to split.

    sizeSplits

    list containing the sizes of each output tensor along the split dimension. Must sum to the dimension of value along split_dim. Can contain one -1 indicating that dimension is to be inferred.

    splitDim

    0-D. The dimension along which to split. Must be in the range [-rank(value), rank(value)).

    Return Value

    Tensors whose shape matches that of value except along axis, where their sizes are size_splits[i].