N-D T 類型張量的 BatchToSpace。
用法
tf.batch_to_space(
input, block_shape, crops, name=None
)參數
-
input具有形狀input_shape = [batch] + spatial_shape + remaining_shape的 N-DTensor,其中spatial_shape具有 M 維。 -
block_shape形狀為 [M] 的一維Tensor。必須是以下類型之一:int32,int64。所有值都必須 >= 1。為了與 TF 1.0 向後兼容,此參數可能是 int,在這種情況下,它會轉換為numpy.array([block_shape, block_shape], dtype=numpy.int64)。 -
crops二維Tensor有形狀[M, 2].必須是以下類型之一:int32,int64.所有值必須 >= 0。crops[i] = [crop_start, crop_end]指定從輸入維度裁剪的數量i + 1, 對應於空間維度i.要求crop_start[i] + crop_end[i] <= block_shape[i] * input_shape[i + 1].此操作等效於以下步驟:- 將
input重塑為reshapedof shape:[block_shape[0], ..., block_shape[M-1], batch /prod(block_shape), input_shape[1], ..., input_shape[N-1] ] - 置換
reshaped的尺寸以產生形狀為 [batch /prod(block_shape), input_shape[1], block_shape[0], ..., input_shape[M], block_shape[M-1], input_shape[M] 的permuted+1], ..., input_shape[N-1]] - 重塑
permuted以生成形狀為reshaped_permuted[batch /prod(block_shape), input_shape[1] * block_shape[0], ..., input_shape[M] * block_shape[M-1], input_shape[M+1 ], ..., input_shape[N-1]] - 根據
crops裁剪reshaped_permuted的維度[1, ..., M]的開始和結束以產生shape的輸出:[batch /prod(block_shape), input_shape[1] * block_shape[0] - crop[0,0] - crop[0,1], ..., input_shape[M] * block_shape[M-1] - crop[M-1,0] - crop[M-1,1], input_shape[M+1], . ..,輸入形狀[N-1]]
- 將
-
name操作的名稱(可選)。
返回
-
一個
Tensor。具有與input相同的類型。
此操作將 "batch" 維度 0 重塑為形狀 block_shape + [batch] 的 M + 1 維度,將這些塊交錯回到由空間維度 [1, ..., M] 定義的網格中,以獲得與輸入具有相同等級的結果。然後根據crops 選擇性地裁剪此中間結果的空間維度以生成輸出。這是 SpaceToBatch 的反麵(參見 tf.space_to_batch )。
例子:
對於以下形狀
[4, 1, 1, 1],block_shape = [2, 2]和crops = [[0, 0], [0, 0]]的輸入:[[[[1]]], [[[2]]], [[[3]]], [[[4]]]]輸出張量的形狀為
[1, 2, 2, 1]和值:x = [[[[1], [2]], [[3], [4]]]]對於以下形狀
[4, 1, 1, 3],block_shape = [2, 2]和crops = [[0, 0], [0, 0]]的輸入:[[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]]輸出張量的形狀為
[1, 2, 2, 3]和值:x = [[[[1, 2, 3], [4, 5, 6 ]], [[7, 8, 9], [10, 11, 12]]]]對於以下形狀
[4, 2, 2, 1],block_shape = [2, 2]和crops = [[0, 0], [0, 0]]的輸入:x = [[[[1], [3]], [[ 9], [11]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]]輸出張量的形狀為
[1, 4, 4, 1]和值:x = [[[1], [2], [ 3], [ 4]], [[5], [6], [ 7], [ 8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]對於以下形狀
[8, 1, 3, 1],block_shape = [2, 2]和crops = [[0, 0], [2, 0]]的輸入:x = [[[[0], [ 1], [ 3]]], [[[0], [ 9], [11]]], [[[0], [ 2], [ 4]]], [[[0], [10], [12]]], [[[0], [ 5], [ 7]]], [[[0], [13], [15]]], [[[0], [ 6], [ 8]]], [[[0], [14], [16]]]]輸出張量的形狀為
[2, 2, 4, 1]和值:x = [[[[ 1], [ 2], [ 3], [ 4]], [[ 5], [ 6], [ 7], [ 8]]], [[[ 9], [10], [11], [12]], [[13], [14], [15], [16]]]]
相關用法
- Python tf.bitcast用法及代碼示例
- Python tf.boolean_mask用法及代碼示例
- Python tf.broadcast_to用法及代碼示例
- Python tf.bitwise.bitwise_or用法及代碼示例
- Python tf.broadcast_static_shape用法及代碼示例
- Python tf.broadcast_dynamic_shape用法及代碼示例
- Python tf.bitwise.bitwise_and用法及代碼示例
- Python tf.bitwise.bitwise_xor用法及代碼示例
- Python tf.bitwise.invert用法及代碼示例
- Python tf.bitwise.right_shift用法及代碼示例
- Python tf.bitwise.left_shift用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.summary.scalar用法及代碼示例
- Python tf.linalg.LinearOperatorFullMatrix.matvec用法及代碼示例
- Python tf.linalg.LinearOperatorToeplitz.solve用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.batch_to_space。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
