将输入元素(嵌套)组合成窗口(嵌套)的数据集。
用法
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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。