Ouw*_*ang 4 tensorflow tensorflow-datasets
在tensorflow 1.12中有Dataset.zip功能:在此处记录。
但是,我想知道是否存在一个数据集解压缩函数,该函数将返回原始的两个数据集。
# 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) }
Run Code Online (Sandbox Code Playgroud)
我想要以下
dataset = Dataset.zip((a, d)) == { (1, 13), (2, 14) }
a, d = dataset.unzip()
Run Code Online (Sandbox Code Playgroud)
我的解决方法是仅使用map,但是不确定以后是否会对语法糖功能感兴趣unzip。
a = dataset.map(lambda a, b: a)
b = dataset.map(lambda a, b: b)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
909 次 |
| 最近记录: |