3.8 KiB
Eye
@sphinxdirective
Versioned name: Eye-9
Category: Generation
Short description: Eye operation generates shift matrix or a batch of matrices.
Detailed description:
Eye operation generates an identity matrix or a batch matrices with ones on the diagonal and zeros everywhere else. The index of the diagonal to be populated with ones is given by diagonal_index: output[..., i, i + diagonal_index] = 1.
Example 1. Eye output with output_type = i32:
.. code-block:: cpp
num_rows = 3
num_columns = 4
diagonal_index = 2
output = [[0 0 1 0] [0 0 0 1] [0 0 0 0]]
Example 2. Eye output with output_type = i32:
.. code-block:: cpp
num_rows = 3
num_columns = 4
diagonal_index = -1
output = [[0 0 0 0] [1 0 0 0] [0 1 0 0]]
Example 3. Eye output with output_type = f16:
.. code-block:: cpp
num_rows = 2
diagonal_index = 5
batch_shape = [1, 2]
output = [[[[0. 0.] [0. 0.]] [[0. 0.] [0. 0.]]]]
Attributes:
-
output_type
- Description: the type of the output
- Range of values: any numeric type
- Type:
string - Required: Yes
Inputs:
- 1:
num_rows- scalar or 1D tensor with 1 non-negative element of type T_NUM describing the number of rows in matrix. Required. - 2:
num_columns- scalar or 1D tensor with 1 non-negative element of type T_NUM describing the number of columns in matrix. Required. - 3:
diagonal_index- scalar or 1D tensor with element of type T_NUM describing the index of the diagonal to be populated. A positive value refers to an upper diagonal and a negative value refers to a lower diagonal. Value0populates the main diagonal. Ifdiagonal_indexis a positive value and is not smaller thannum_rowsor ifdiagonal_indexis a negative value and is not larger thannum_columns, the matrix will be filled with only zeros. Required. - 4:
batch_shape- 1D tensor with non-negative values of type T_NUM defines leading batch dimensions of output shape. Ifbatch_shapeis an empty list, Eye operation generates a 2D tensor (matrix). This input is optional, and its default value equal to an empty tensor.
Outputs:
- 1: A tensor with the type specified by the output_type attribute. The shape is
batch_shape + [num_rows, num_columns]
Types
- T_NUM:
int32orint64.
Examples
Example 1
.. code-block:: cpp
<layer ... name="Eye" type="Eye"> < !-- num rows: 5 --> < !-- num columns: 5 --> < !-- diagonal index --> 5 5
Example 2
.. code-block:: cpp
<layer ... name="Eye" type="Eye"> < !-- num rows --> < !-- num columns --> < !-- diagonal index --> < !-- batch_shape : [2, 3] --> 2 3 -1 -1
@endsphinxdirective