W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
reverse(
tensor,
axis,
name=None
)
定義在:tensorflow/python/ops/array_ops.py.
參見(jiàn)指南:張量變換>分割和連接
反轉(zhuǎn)張量的特定維度.
注意tf.reverse現(xiàn)在已經(jīng)改變了為1.0準(zhǔn)備的行為.tf.reverse_v2目前是一個(gè)別名,將在 tf 1.0 之前棄用.
給定一個(gè)tensor和一個(gè)int32類(lèi)型的張量axis,以表示要反轉(zhuǎn)的tensor的一組維度.此操作反轉(zhuǎn)每個(gè)維度 i ,其中存在 j,例如:axis[j] == i.
tensor可以有多達(dá)8個(gè)維度.指定的維數(shù)axis可以是0或更多的條目.如果多次指定索引,則會(huì)引發(fā)InvalidArgument錯(cuò)誤.
例如:
# tensor 't' is [[[[ 0, 1, 2, 3],
# [ 4, 5, 6, 7],
# [ 8, 9, 10, 11]],
# [[12, 13, 14, 15],
# [16, 17, 18, 19],
# [20, 21, 22, 23]]]]
# tensor 't' shape is [1, 2, 3, 4]
# 'dims' is [3] or 'dims' is -1
reverse(t, dims) ==> [[[[ 3, 2, 1, 0],
[ 7, 6, 5, 4],
[ 11, 10, 9, 8]],
[[15, 14, 13, 12],
[19, 18, 17, 16],
[23, 22, 21, 20]]]]
# 'dims' is '[1]' (or 'dims' is '[-3]')
reverse(t, dims) ==> [[[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]
[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]]]]
# 'dims' is '[2]' (or 'dims' is '[-2]')
reverse(t, dims) ==> [[[[8, 9, 10, 11],
[4, 5, 6, 7],
[0, 1, 2, 3]]
[[20, 21, 22, 23],
[16, 17, 18, 19],
[12, 13, 14, 15]]]]
參數(shù):
返回:
該函數(shù)將返回一個(gè) Tensor.與tensor具有相同的類(lèi)型和形狀.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: