W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
tf.matrix_diag 函數(shù)
matrix_diag(
diagonal,
name=None
)
參考指南:數(shù)學(xué)函數(shù)>矩陣數(shù)學(xué)函數(shù)
返回具有給定批對(duì)角線(xiàn)值的批對(duì)角張量.
給定一個(gè)對(duì)角線(xiàn)(diagonal),這個(gè)操作將返回一個(gè)帶有對(duì)角線(xiàn)的張量,而其他所有的東西都加0.對(duì)角線(xiàn)的計(jì)算如下:
假設(shè)對(duì)角線(xiàn)具有 k 維度 [I, J, K, ..., N],則輸出是秩為 k+1 且維度為 [I,J,K,...,N,N] 的張量,其中:
output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n]
例如:
# 'diagonal' is [[1, 2, 3, 4], [5, 6, 7, 8]]
and diagonal.shape = (2, 4)
tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0]
[0, 2, 0, 0]
[0, 0, 3, 0]
[0, 0, 0, 4]],
[[5, 0, 0, 0]
[0, 6, 0, 0]
[0, 0, 7, 0]
[0, 0, 0, 8]]]
which has shape (2, 4, 4)
參數(shù):
返回值:
該函數(shù)將返回張量,該張量與 diagonal 具有相同的類(lèi)型;秩為 k+1,并且 output.shape = diagonal.shape + [diagonal.shape[-1]].
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: