View source on GitHub |
Gather slices with indices=-1
mapped to default
.
text.gather_with_default(
params, indices, default, name=None, axis=0
)
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'c', b'a', b'_', b'c', b'_'], dtype=object)>
Returns | |
---|---|
A Tensor with the same type as param , and with shape
params.shape[:axis] + indices.shape + params.shape[axis + 1:] .
|