W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
tf.transpose(
a,
perm=None,
name='transpose',
conjugate=False
)
定義在:tensorflow/python/ops/array_ops.py.
請參閱指南:數(shù)學(xué)函數(shù)>矩陣數(shù)學(xué)函數(shù),張量變換>分割和連接
置換 a,根據(jù) perm 重新排列尺寸.
返回的張量的維度 i 將對應(yīng)于輸入維度 perm[i].如果 perm 沒有給出,它被設(shè)置為(n-1 ... 0),其中 n 是輸入張量的秩.因此,默認(rèn)情況下,此操作在二維輸入張量上執(zhí)行常規(guī)矩陣轉(zhuǎn)置.如果共軛為 True,并且 a.dtype 是 complex64 或 complex128,那么 a 的值是共軛轉(zhuǎn)置和.
例如:
x = tf.constant([[1, 2, 3], [4, 5, 6]])
tf.transpose(x) # [[1, 4]
# [2, 5]
# [3, 6]]
# Equivalently
tf.transpose(x, perm=[1, 0]) # [[1, 4]
# [2, 5]
# [3, 6]]
# If x is complex, setting conjugate=True gives the conjugate transpose
x = tf.constant([[1 + 1j, 2 + 2j, 3 + 3j],
[4 + 4j, 5 + 5j, 6 + 6j]])
tf.transpose(x, conjugate=True) # [[1 - 1j, 4 - 4j],
# [2 - 2j, 5 - 5j],
# [3 - 3j, 6 - 6j]]
# 'perm' is more useful for n-dimensional tensors, for n > 2
x = tf.constant([[[ 1, 2, 3],
[ 4, 5, 6]],
[[ 7, 8, 9],
[10, 11, 12]]])
# Take the transpose of the matrices in dimension-0
# (this common operation has a shorthand `matrix_transpose`)
tf.transpose(x, perm=[0, 2, 1]) # [[[1, 4],
# [2, 5],
# [3, 6]],
# [[7, 10],
# [8, 11],
# [9, 12]]]
函數(shù)參數(shù):
返回:
tf.transpose 函數(shù)返回一個轉(zhuǎn)置 Tensor.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: