神剑山庄资源网 Design By www.hcban.com
tf.diag(diagonal,name=None) #生成对角矩阵
import tensorflowas tf; diagonal=[1,1,1,1] with tf.Session() as sess: print(sess.run(tf.diag(diagonal)))
#输出的结果为[[1 0 0 0] [0 1 0 0] [0 0 1 0] [0 0 0 1]]
tf.diag_part(input,name=None) #功能与tf.diag函数相反,返回对角阵的对角元素
import tensorflow as tf; diagonal =tf.constant([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]) with tf.Session() as sess: print(sess.run(tf.diag_part(diagonal)))
#输出结果为[1,1,1,1]
tf.trace(x,name=None) #求一个2维Tensor足迹,即为对角值diagonal之和
import tensorflow as tf; diagonal =tf.constant([[1,0,0,3],[0,1,2,0],[0,1,1,0],[1,0,0,1]]) with tf.Session() as sess: print(sess.run(tf.trace(diagonal)))#输出结果为4
tf.transpose(a,perm=None,name='transpose') #调换tensor的维度顺序,按照列表perm的维度排列调换tensor的顺序
import tensorflow as tf; diagonal =tf.constant([[1,0,0,3],[0,1,2,0],[0,1,1,0],[1,0,0,1]]) with tf.Session() as sess: print(sess.run(tf.transpose(diagonal))) #输出结果为[[1 0 0 1] [0 1 1 0] [0 2 1 0] [3 0 0 1]]
tf.matmul(a,b,transpose_a=False,transpose_b=False,a_is_sparse=False,b_is_sparse=False,name=None) #矩阵相乘
transpose_a=False,transpose_b=False #运算前是否转置
a_is_sparse=False,b_is_sparse=False #a,b是否当作系数矩阵进行运算
import tensorflow as tf; A =tf.constant([1,0,0,3],shape=[2,2]) B =tf.constant([2,1,0,2],shape=[2,2]) with tf.Session() as sess: print(sess.run(tf.matmul(A,B)))
#输出结果为[[2 1] [0 6]]
tf.matrix_determinant(input,name=None) #计算行列式
import tensorflow as tf; A =tf.constant([1,0,0,3],shape=[2,2],dtype=tf.float32) with tf.Session() as sess: print(sess.run(tf.matrix_determinant(A)))
#输出结果为3.0
tf.matrix_inverse(input,adjoint=None,name=None)
adjoint决定计算前是否进行转置
import tensorflow as tf; A =tf.constant([1,0,0,2],shape=[2,2],dtype=tf.float64) with tf.Session() as sess: print(sess.run(tf.matrix_inverse(A)))
#输出结果为[[ 1. 0. ] [ 0. 0.5]]
tf.cholesky(input,name=None) #对输入方阵cholesky分解,即为将一个对称正定矩阵表示成一个下三角矩阵L和其转置的乘积德分解
import tensorflow as tf; A =tf.constant([1,0,0,2],shape=[2,2],dtype=tf.float64) with tf.Session() as sess: print(sess.run(tf.cholesky(A)))
#输出结果为[[ 1. 0. ] [ 0. 1.41421356]]
以上这篇对Tensorflow中的矩阵运算函数详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
标签:
Tensorflow,矩阵,函数
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无对Tensorflow中的矩阵运算函数详解的评论...
更新日志
2024年10月02日
2024年10月02日
- 孙悦.1996-伙伴【正大国际】【WAV+CUE】
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】