- 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.
推薦閱讀
- LibGDX Game Development Essentials
- Python絕技:運(yùn)用Python成為頂級(jí)數(shù)據(jù)工程師
- 數(shù)據(jù)庫(kù)基礎(chǔ)與應(yīng)用:Access 2010
- 使用GitOps實(shí)現(xiàn)Kubernetes的持續(xù)部署:模式、流程及工具
- 云計(jì)算與大數(shù)據(jù)應(yīng)用
- Python數(shù)據(jù)分析:基于Plotly的動(dòng)態(tài)可視化繪圖
- Remote Usability Testing
- 數(shù)據(jù)庫(kù)原理與應(yīng)用(Oracle版)
- MySQL 8.x從入門到精通(視頻教學(xué)版)
- 辦公應(yīng)用與計(jì)算思維案例教程
- 信息融合中估計(jì)算法的性能評(píng)估
- 利用Python進(jìn)行數(shù)據(jù)分析(原書(shū)第2版)
- 數(shù)據(jù)分析思維:產(chǎn)品經(jīng)理的成長(zhǎng)筆記
- Unity for Architectural Visualization
- 數(shù)據(jù)迷霧:洞察數(shù)據(jù)的價(jià)值與內(nèi)涵