- Neural Network Programming with TensorFlow
- Manpreet Singh Ghotra Rajdeep Dua
- 68字
- 2021-07-02 15:17:08
Identity matrix
An identity matrix is a matrix I that does not change any vector, like V, when multiplied by I.
The following example shows how to get the identity matrix for a given size:
import tensorflow as tf
identity = tf.eye(3, 3)
with tf.Session() as sess:
print(sess.run(identity))
The output of this is shown as follows:
[[ 1. 0. 0.] [ 0. 1. 0.] [ 0. 0. 1.]]