W3cubDocs

/TensorFlow

tf.keras.ops.eye

Return a 2-D tensor with ones on the diagonal and zeros elsewhere.

Args
N Number of rows in the output.
M Number of columns in the output. If None, defaults to N.
k Index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.
dtype Data type of the returned tensor.
Returns
Tensor with ones on the k-th diagonal and zeros elsewhere.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/ops/eye