MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / gather

Function gather

tensorflow/python/ops/array_ops.py:3869–3966  ·  view source on GitHub ↗

r"""Gather slices from params axis axis according to indices. Gather slices from params axis `axis` according to `indices`. `indices` must be an integer tensor of any dimension (usually 0-D or 1-D). For 0-D (scalar) `indices`: > `output`$$[p_0, ..., p_{axis-1}, \hspace{5.

(params,
           indices,
           validate_indices=None,
           name=None,
           axis=None,
           batch_dims=0,
           ev_init_value=None,
           counts=None)

Source from the content-addressed store, hash-verified

3867@tf_export(v1=["gather"])
3868@dispatch.add_dispatch_support
3869def gather(params,
3870 indices,
3871 validate_indices=None,
3872 name=None,
3873 axis=None,
3874 batch_dims=0,
3875 ev_init_value=None,
3876 counts=None): # pylint: disable=g-doc-args
3877 r"""Gather slices from params axis axis according to indices.
3878
3879 Gather slices from params axis `axis` according to `indices`. `indices` must
3880 be an integer tensor of any dimension (usually 0-D or 1-D).
3881
3882 For 0-D (scalar) `indices`:
3883
3884 > `output`$$[p_0, ..., p_{axis-1}, \hspace{5.1em}
3885 > p_{axis + 1}, ..., p_{N-1}]$$ =\
3886 > `params`$$[p_0, ..., p_{axis-1}, \hspace{1em}
3887 > indices, \hspace{1em}
3888 > p_{axis + 1}, ..., p_{N-1}]$$.
3889
3890 For 1-D (vector) `indices` with `batch_dims=0`:
3891
3892 > `output`$$[p_0, ..., p_{axis-1}, \hspace{2.6em}
3893 > i, \hspace{2.6em}
3894 > p_{axis + 1}, ..., p_{N-1}]$$ =\
3895 > `params`$$[p_0, ..., p_{axis-1}, \hspace{1em}
3896 > indices[i], \hspace{1em}
3897 > p_{axis + 1}, ..., p_{N-1}]$$.
3898
3899 In the general case, produces an output tensor where:
3900
3901 $$\begin{align*}
3902 output[p_0, &..., p_{axis-1}, &
3903 &i_{B}, ..., i_{M-1}, &
3904 p_{axis + 1}, &..., p_{N-1}] = \\
3905 params[p_0, &..., p_{axis-1}, &
3906 indices[p_0, ..., p_{B-1}, &i_{B}, ..., i_{M-1}], &
3907 p_{axis + 1}, &..., p_{N-1}]
3908 \end{align*}$$
3909
3910 Where $$N$$=`ndims(params)`, $$M$$=`ndims(indices)`, and $$B$$=`batch_dims`.
3911 Note that params.shape[:batch_dims] must be identical to
3912 indices.shape[:batch_dims].
3913
3914 The shape of the output tensor is:
3915
3916 > `output.shape = params.shape[:axis] + indices.shape[batch_dims:] +
3917 > params.shape[axis + 1:]`.
3918
3919 Note that on CPU, if an out of bound index is found, an error is returned.
3920 On GPU, if an out of bound index is found, a 0 is stored in the corresponding
3921 output value.
3922
3923 See also `tf.gather_nd`.
3924
3925 <div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;">
3926 <img style="width:100%" src="https://www.tensorflow.org/images/Gather.png"

Callers 4

_apply_mask_1dFunction · 0.70
sparse_maskFunction · 0.70
gather_v2Function · 0.70
_batch_gatherFunction · 0.70

Calls 1

sparse_readMethod · 0.45

Tested by

no test coverage detected