tensorflow dataset_ops batch()方法 (将此数据集的连续元素合并为批)
生活随笔
收集整理的这篇文章主要介绍了
tensorflow dataset_ops batch()方法 (将此数据集的连续元素合并为批)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
from python\data\ops\dataset_ops.py
def batch(self, batch_size, drop_remainder=False):"""Combines consecutive elements of this dataset into batches.将此数据集的连续元素合并为批。The tensors in the resulting element will have an additional outerdimension, which will be `batch_size` (or `N % batch_size` for the lastelement if `batch_size` does not divide the number of input elements `N`evenly and `drop_remainder` is `False`). If your program depends on thebatches having the same outer dimension, you should set the `drop_remainder`argument to `True` to prevent the smaller batch from being produced.结果元素中的张量将具有一个附加的外部尺寸,该尺寸将为`batch_size`(或最后一个元素的`N%batch_size`,如果`batch_size`不能将输入元素`N`的数量均匀划分和`drop_remainder` 是“假”)。 如果您的程序依赖于具有相同外部尺寸的批次,则应将drop_remainder参数设置为True,以防止产生较小的批次。Args:batch_size: A `tf.int64` scalar `tf.Tensor`, representing the number ofconsecutive elements of this dataset to combine in a single batch.tf.int64标量tf.Tensor,表示要在单个批次中合并的此数据集的连续元素数。drop_remainder: (Optional.) A `tf.bool` scalar `tf.Tensor`, representingwhether the last batch should be dropped in the case its has fewer than`batch_size` elements; the default behavior is not to drop the smallerbatch.tf.bool标量tf.Tensor,表示如果最后一个批次的数量少于`batch_size`个元素,是否应删除最后一个批次; 默认行为是不删除较小的批次。Returns:Dataset: A `Dataset`. 数据集:一个“数据集”。"""return BatchDataset(self, batch_size, drop_remainder)总结
以上是生活随笔为你收集整理的tensorflow dataset_ops batch()方法 (将此数据集的连续元素合并为批)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: tensorflow dataset_o
- 下一篇: pycharm 报错 Indentati