Tensorflow中Dataset对象的apply()、map()和flat_map()方法间的区别

apply()、map()和flat_map()三中方法都可以用于转换Dataset对象中的数据。它们的区别是

方法官网原文作者理解
apply()

Applies a transformation function to this dataset. apply enables chaining of custom Dataset transformations, which are represented as functions that take one Dataset argument and return a transformed Dataset.

apply() 方法将转换函数应用于输入Dataset,返回结果是转换后的新Dataset

map()

Maps map_func across the elements of this dataset. This transformation applies map_func to each element of this dataset, and returns a new dataset containing the transformed elements, in the same order as they appeared in the input. map_func can be used to change both the values and the structure of a dataset’s elements.

map() 方法将转换函数依次应用于输入Dataset中的每一个元素(element),返回结果是转换后的新Dataset

flat_map()

Maps map_func across this dataset and flattens the result.

flat_map() 方法是将Dataset对象中的数据先展平形成一个新的Dataset,然后转换函数应用于这个新Dataset,并返回转换结果(是一个Dataset)。ps:相当于先将输入Dataset展平,然后再对展平后的Dataset应用一次apply()方法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值