Skip to content

Instantly share code, notes, and snippets.

Created July 10, 2016 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/40d17daec74007e7b874d626f560d22f to your computer and use it in GitHub Desktop.
Save anonymous/40d17daec74007e7b874d626f560d22f to your computer and use it in GitHub Desktop.
How to initialize matrix as identity matrix with TensorFlow
>>> mat1 = tf.diag(tf.ones((1,3)))
>>> print(mat1.eval())
[[[[ 1. 0. 0.]]
[[ 0. 1. 0.]]
[[ 0. 0. 1.]]]]
@lorenlugosch
Copy link

nice, thanks for this!

@NiziL
Copy link

NiziL commented Apr 3, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment