• Splits a tf.Tensor into sub tensors.

    If numOrSizeSplits is a number, splits x along dimension axis into numOrSizeSplits smaller tensors. Requires that numOrSizeSplits evenly divides x.shape[axis].

    If numOrSizeSplits is a number array, splits x into numOrSizeSplits.length pieces. The shape of the i-th piece has the same size as x except along dimension axis where the size is numOrSizeSplits[i].

    const x = tf.tensor2d([1, 2, 3, 4, 5, 6, 7, 8], [2, 4]);
    const [a, b] = tf.split(x, 2, 1);
    a.print();
    b.print();

    const [c, d, e] = tf.split(x, [1, 2, 1], 1);
    c.print();
    d.print();
    e.print();

    Type Parameters

    Parameters

    • x: Tensor<Rank> | TensorLike

      The input tensor to split.

    • numOrSizeSplits: number | number[]

      Either an integer indicating the number of splits along the axis or an array of integers containing the sizes of each output tensor along the axis. If a number then it must evenly divide x.shape[axis]; otherwise the sum of sizes must match x.shape[axis]. Can contain one -1 indicating that dimension is to be inferred.

    • Optional axis: number

      The dimension along which to split. Defaults to 0 (the first dim).

    Returns T[]

    Doc

Generated using TypeDoc