官术网_书友最值得收藏!

Trace operator

The trace operator Tr(A) of matrix A gives the sum of all of the diagonal entries of a matrix. The following example shows how to use a trace operator on tensor objects:

import tensorflow as tf

mat = tf.constant([
[0, 1, 2],
[3, 4, 5],
[6, 7, 8]
], dtype=tf.float32)

# get trace ('sum of diagonal elements') of the matrix
mat = tf.trace(mat)

with tf.Session() as sess:
print(sess.run(mat))

The output of the listing is 12.0.

主站蜘蛛池模板: 阿坝| 综艺| 弥渡县| 通河县| 桃园县| 西昌市| 长泰县| 甘孜| 宁德市| 崇信县| 东至县| 罗定市| 南汇区| 礼泉县| 皮山县| 石景山区| 监利县| 新源县| 新建县| 海宁市| 新田县| 渭南市| 青川县| 东莞市| 什邡市| 察雅县| 云浮市| 东山县| 霍林郭勒市| 葵青区| 伽师县| 昆明市| 犍为县| 鄢陵县| 上饶县| 石城县| 南汇区| 合阳县| 修武县| 汤原县| 河津市|