Welcome to our Support Center

Gather

Description

It is an indexing operation that indexes into the input data along a single (specified) axis. Each entry in indices produces a r-1 dimensional slice of the input tensor. The entire operation produces, conceptually, a q-dimensional tensor of r-1 dimensional slices, which is arranged into a q + (r-1)-dimensional tensor, with the q dimensions taking the place of the original axis that is being indexed into.

 

 

Given data tensor of rank r >= 1, and indices tensor of rank q, gather entries of the axis dimension of data (by default outer-most one as axis=0) indexed by indices, and concatenates them in an output tensor of rank q + (r – 1).

The following few examples illustrate how Gather works for specific shapes of dataindices, and given value of axis :

 

data shape indices shape axis output shape output equation
(P, Q) ( ) (a scalar) 0 (Q) output[q] = data[indices, q]
(P, Q, R) ( ) (a scalar) 1 (P, R) output[p, r] = data[p, indices, r]
(P, Q) (R, S) 0 (R, S, Q) output[r, s, q] = data[ [indices[r, s], q]
(P, Q) (R, S) 1 (P, R, S) output[p, r, s] = data[ p, indices[r, s]]

 

Input parameters

 

specified_outputs_namearray, this parameter lets you manually assign custom names to the output tensors of a node.

 Graphs in : cluster, ONNX model architecture.

 data (heterogeneous) – T : object, tensor of rank r >= 1.
 indices (heterogeneous) – Tind : object, tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.

 Parameters : cluster,

axis : integer, which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).
Default value “0”.
 training? : boolean, whether the layer is in training mode (can store data for backward).
Default value “True”.
 lda coeff : float, defines the coefficient by which the loss derivative will be multiplied before being sent to the previous layer (since during the backward run we go backwards).
Default value “1”.

 name (optional) : string, name of the node.

Output parameters

 

 output (heterogeneous) – T : object, tensor of rank q + (r – 1).

Type Constraints

T in (tensor(bfloat16)tensor(bool)tensor(complex128)tensor(complex64)tensor(double)tensor(float)tensor(float16)
tensor(int16)tensor(int32)tensor(int64)tensor(int8)tensor(string)tensor(uint16)tensor(uint32)tensor(uint64)tensor(uint8)) : Constrain input and output types to any tensor type.

Tind in (tensor(int32)tensor(int64)) : Constrain indices to integer types.

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).
Table of Contents