將輸入元素(嵌套)組合成窗口(嵌套)的數據集。
用法
tf.raw_ops.WindowDataset(
input_dataset, size, shift, stride, drop_remainder, output_types, output_shapes,
metadata='', name=None
)
參數
-
input_dataset
Tensor
類型為variant
。 -
size
Tensor
類型為int64
。一個整數標量,表示要組合到一個窗口中的輸入數據集元素的數量。必須是積極的。 -
shift
Tensor
類型為int64
。一個整數標量,表示窗口在每次迭代中移動的輸入元素的數量。默認為size
。必須是積極的。 -
stride
Tensor
類型為int64
。一個整數標量,表示滑動窗口中輸入元素的步幅。必須是積極的。默認值 1 表示“保留每個輸入元素”。 -
drop_remainder
Tensor
類型為bool
。一個布爾標量,表示如果最後一個窗口的大小小於window_size
,是否應該刪除最後一個窗口。 -
output_types
長度為>= 1
的tf.DTypes
列表。 -
output_shapes
長度為>= 1
的形狀列表(每個tf.TensorShape
或ints
列表)。 -
metadata
可選的string
。默認為""
。 -
name
操作的名稱(可選)。
返回
-
Tensor
類型為variant
。
"window" 是大小為 size
的平麵元素的有限數據集(如果沒有足夠的輸入元素來填充窗口並且 drop_remainder
評估為假,則可能更少)。
shift
參數確定窗口在每次迭代中移動的輸入元素的數量。 k
th 窗口中的第一個元素將是元素
1 + (k-1) * shift
的輸入數據集。特別是,第一個窗口的第一個元素將始終是輸入數據集的第一個元素。
如果stride
參數大於1,則每個窗口將跳過窗口中出現的每個元素之間的(stride - 1)
輸入元素。無論 stride
的值如何,輸出窗口仍將包含 size
元素。
stride
參數確定輸入元素的步幅,shift
參數確定窗口的位移。
例如,讓{...}
表示一個數據集:
tf.data.Dataset.range(7).window(2)
產生{ {0, 1}, {2, 3}, {4, 5}, {6} }
tf.data.Dataset.range(7).window(3, 2, 1, True)
產生{ {0, 1, 2}, {2, 3, 4}, {4, 5, 6} }
tf.data.Dataset.range(7).window(3, 1, 2, True)
產生{ {0, 2, 4}, {1, 3, 5}, {2, 4, 6} }
請注意,當 window
轉換應用於嵌套元素的數據集時,它會生成嵌套窗口的數據集。
例如:
tf.data.Dataset.from_tensor_slices((range(4), range(4))).window(2)
生產{({0, 1}, {0, 1}), ({2, 3}, {2, 3})}
tf.data.Dataset.from_tensor_slices({"a":range(4)}).window(2)
產生{ {"a":{0, 1} }, {"a":{2, 3} } }
相關用法
- Python tf.raw_ops.Where用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代碼示例
- Python tf.raw_ops.BatchMatMul用法及代碼示例
- Python tf.raw_ops.OneHot用法及代碼示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代碼示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代碼示例
- Python tf.raw_ops.GatherV2用法及代碼示例
- Python tf.raw_ops.Expm1用法及代碼示例
- Python tf.raw_ops.BitwiseAnd用法及代碼示例
- Python tf.raw_ops.UniqueWithCounts用法及代碼示例
- Python tf.raw_ops.DecodeGif用法及代碼示例
- Python tf.raw_ops.Size用法及代碼示例
- Python tf.raw_ops.ScatterUpdate用法及代碼示例
- Python tf.raw_ops.ParallelConcat用法及代碼示例
- Python tf.raw_ops.ScatterNdUpdate用法及代碼示例
- Python tf.raw_ops.BatchToSpaceND用法及代碼示例
- Python tf.raw_ops.TensorScatterMax用法及代碼示例
- Python tf.raw_ops.DepthToSpace用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.raw_ops.WindowDataset。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。