eye

dragon.vm.tensorflow.eye(
  num_rows,
  num_columns=None,
  dtype='float32',
  name=None
)[source]

Return a tensor constructed as the identity matrix.

\[\text{out} \leftarrow \text{diag}(1, 1, ..., 1) \]

Matrix shape are determined by num_rows and num_columns:

print(tf.eye(2))  # [[1., 0.], [0., 1.]]
print(tf.eye(2, num_columns=3))  # [[1., 0., 0.], [0., 1., 0.]]
Parameters:
  • num_rows (Union[int, dragon.Tensor]) – The number output rows.
  • num_columns (Union[int, dragon.Tensor], optional) – The number output cols.
  • dtype (str, optional, default='float32') – The optional data type.
  • name (str, optional) – The operation name.
Returns:

dragon.Tensor – The output tensor.