- 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.
推薦閱讀
- ETL數據整合與處理(Kettle)
- Python絕技:運用Python成為頂級數據工程師
- Effective Amazon Machine Learning
- 使用GitOps實現Kubernetes的持續部署:模式、流程及工具
- 數據要素五論:信息、權屬、價值、安全、交易
- 大數據時代下的智能轉型進程精選(套裝共10冊)
- 數據庫程序員面試筆試真題庫
- 高維數據分析預處理技術
- 智慧的云計算
- 企業大數據處理:Spark、Druid、Flume與Kafka應用實踐
- MySQL數據庫實用教程
- Scratch 2.0 Game Development HOTSHOT
- 數據挖掘與機器學習-WEKA應用技術與實踐(第二版)
- 工業大數據融合體系結構與關鍵技術
- 高效使用Redis:一書學透數據存儲與高可用集群