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

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.

主站蜘蛛池模板: 镇原县| 平罗县| 台中县| 甘德县| 蓬莱市| 浦县| 应城市| 罗甸县| 梧州市| 万州区| 新乡市| 自治县| 清镇市| 阜新市| 尤溪县| 海安县| 开原市| 南京市| 湾仔区| 醴陵市| 从化市| 玛纳斯县| 高陵县| 开阳县| 兰西县| 隆昌县| 常州市| 浦县| 喀什市| 辽源市| 广州市| 白朗县| 垣曲县| 孙吴县| 焦作市| 夏邑县| 吉木乃县| 东港市| 永德县| 乌苏市| 永和县|