In [1]:
import tensorflow as tf

Matrix functions

tf.diag


In [16]:
matrix_diag = tf.constant([7,8,9,10])

In [17]:
matrix_diag_function = tf.diag(matrix_diag)

In [18]:
with tf.Session() as ses:
    print ses.run(matrix_diag_function)


[[ 7  0  0  0]
 [ 0  8  0  0]
 [ 0  0  9  0]
 [ 0  0  0 10]]

tf.transpose


In [19]:
matrix_transp = tf.constant([[7,8,9],[10,11,12]])

In [20]:
matrix_transp_function = tf.transpose(matrix_transp)

In [21]:
with tf.Session() as ses:
    print ses.run(matrix_transp_function)


[[ 7 10]
 [ 8 11]
 [ 9 12]]

In [ ]: