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

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.

主站蜘蛛池模板: 灵宝市| 花垣县| 鄢陵县| 孟连| 江津市| 册亨县| 泰州市| 和平县| 松滋市| 连城县| 泰顺县| 昌都县| 珠海市| 河东区| 宾川县| 宿迁市| 大关县| 启东市| 德令哈市| 井研县| 安庆市| 桂阳县| 商水县| 额尔古纳市| 南丹县| 连山| 麦盖提县| 库伦旗| 宜兴市| 云和县| 邵阳县| 鹤山市| 米易县| 库车县| 巴林右旗| 四平市| 平定县| 永胜县| 济源市| 南康市| 常德市|