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

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.

主站蜘蛛池模板: 金昌市| 手机| 儋州市| 观塘区| 平和县| 凌海市| 朔州市| 福州市| 闸北区| 万年县| 贵德县| 潮州市| 鄂伦春自治旗| 高阳县| 广州市| 榆中县| 阿拉善右旗| 石棉县| 黎平县| 武穴市| 南木林县| 乌拉特后旗| 济源市| 江川县| 高陵县| 鄯善县| 赣榆县| 五河县| 顺昌县| 安庆市| 呼图壁县| 和静县| 田林县| 开封市| 黄龙县| 博白县| 英山县| 康保县| 沙坪坝区| 策勒县| 海口市|