擅长:python、mysql、java
<p>我没有足够的声誉发表评论,但我只想指出,实际上可以使用map应用于数据集中的多个元素,而不是@sunreef在他自己的帖子中的评论。</p>
<p>根据文档,map以</p>
<blockquote>
<p>map_func: A function mapping a nested structure of tensors (having
shapes and types defined by self.output_shapes and self.output_types)
to another nested structure of tensors.</p>
</blockquote>
<p>输出形状由数据集定义,可以使用批处理等api函数进行修改。因此,例如,您可以仅使用dataset.batch和.map执行批处理规范化:</p>
<pre><code>dataset = dataset ...
dataset.batch(batch_size)
dataset.map(normalize_fn)
</code></pre>
<p>似乎<code>apply()</code>的主要实用程序是当您真正想跨整个数据集进行转换时。</p>