- Neural Network Programming with TensorFlow
- Manpreet Singh Ghotra Rajdeep Dua
- 77字
- 2021-07-02 15:17:07
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.
推薦閱讀
- Voice Application Development for Android
- 云計算服務保障體系
- 數據庫應用基礎教程(Visual FoxPro 9.0)
- Hadoop大數據實戰權威指南(第2版)
- WS-BPEL 2.0 Beginner's Guide
- Hands-On Mathematics for Deep Learning
- 大數據技術入門
- R語言數據挖掘
- 辦公應用與計算思維案例教程
- Unreal Engine Virtual Reality Quick Start Guide
- 二進制分析實戰
- 智慧城市中的大數據分析技術
- 數據庫原理與設計實驗教程(MySQL版)
- 從Lucene到Elasticsearch:全文檢索實戰
- 企業級大數據項目實戰:用戶搜索行為分析系統從0到1