text.gather_with_default

Gather slices with indices=-1 mapped to default.

This operation is similar to tf.gather(), except that any value of -1 in indices will be mapped to default. Example:

gather_with_default(['a', 'b', 'c', 'd'], [2, 0, -1, 2, -1], '_')
<tf.Tensor: shape=(5,), dtype=string,
    numpy=array([b&#x27;c', b'a', b'_', b'c', b'_'], dtype=object)>

params The Tensor from which to gather values. Must be at least rank axis + 1.
indices The index Tensor. Must have dtype int32 or int64, and values must be in the range [-1, params.shape[axis]).
default The value to use when indices is -1. default.shape must be equal to params.shape[axis + 1:].
name A name for the operation (optional).
axis The axis in params to gather indices from. Must be a scalar int32 or int64. Supports negative indices.

A Tensor with the same type as param, and with shape params.shape[:axis] + indices.shape + params.shape[axis + 1:].