gpt4 book ai didi

Tensorflow tf.data.Dataset API,数据集解压功能?

转载 作者:行者123 更新时间:2023-12-04 22:54:52 27 4
gpt4 key购买 nike

在 tensorflow 1.12 中有 Dataset.zip功能:记录 here .

但是,我想知道是否有一个数据集解压缩函数可以返回原始的两个数据集。

# NOTE: The following examples use `{ ... }` to represent the
# contents of a dataset.
a = { 1, 2, 3 }
b = { 4, 5, 6 }
c = { (7, 8), (9, 10), (11, 12) }
d = { 13, 14 }

# The nested structure of the `datasets` argument determines the
# structure of elements in the resulting dataset.
Dataset.zip((a, b)) == { (1, 4), (2, 5), (3, 6) }
Dataset.zip((b, a)) == { (4, 1), (5, 2), (6, 3) }

# The `datasets` argument may contain an arbitrary number of
# datasets.
Dataset.zip((a, b, c)) == { (1, 4, (7, 8)),
(2, 5, (9, 10)),
(3, 6, (11, 12)) }

# The number of elements in the resulting dataset is the same as
# the size of the smallest dataset in `datasets`.
Dataset.zip((a, d)) == { (1, 13), (2, 14) }

我想要以下内容
dataset = Dataset.zip((a, d)) == { (1, 13), (2, 14) }
a, d = dataset.unzip()

最佳答案

我的解决方法是只使用 map,不确定是否可能对 unzip 的语法糖函数感兴趣。后来虽然。

a = dataset.map(lambda a, b: a)
b = dataset.map(lambda a, b: b)

关于Tensorflow tf.data.Dataset API,数据集解压功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53641920/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com