• Apply boolean mask to tensor.

    const tensor = tf.tensor2d([1, 2, 3, 4, 5, 6], [3, 2]);
    const mask = tf.tensor1d([1, 0, 1], 'bool');
    const result = await tf.booleanMaskAsync(tensor, mask);
    result.print();

    Parameters

    • tensor: Tensor<Rank> | TensorLike

      N-D tensor.

    • mask: Tensor<Rank> | TensorLike

      K-D boolean tensor, K <= N and K must be known statically.

    • Optional axis: number

      A 0-D int Tensor representing the axis in tensor to mask from. By default, axis is 0 which will mask from the first dimension. Otherwise K + axis <= N.

    Returns Promise<Tensor>

    Doc

Generated using TypeDoc