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

编程入门 行业动态 更新时间:2024-10-09 17:22:22
本文介绍了Tensorflow tf.data.Dataset API,数据集解压功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

在 tensorflow 1.12 中有 Dataset.zip 函数:记录在 此处.

In tensorflow 1.12 there is the Dataset.zip function: documented here.

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

However, I was wondering if there is a dataset unzip function which will return back the original two datasets.

# 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 的语法糖函数感兴趣.

My workaround was to just use map, not sure if there might be interest in a syntax sugar function for unzip later though.

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

这篇关于Tensorflow tf.data.Dataset API,数据集解压功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 05:16:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405407.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   集解   数据   tf   Tensorflow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!