Dataset.from_tensors和Dataset.from_tensor_slices有什么区别?

Dataset.from_tensors和Dataset.from_tensor_slices有什么区别?,第1张

Dataset.from_tensors和Dataset.from_tensor_slices有什么区别?

from_tensors
合并输入并返回具有单个元素的数据集:

t = tf.constant([[1, 2], [3, 4]])ds = tf.data.Dataset.from_tensors(t)   # [[1, 2], [3, 4]]

from_tensor_slices
为输入张量的每一行创建一个具有单独元素的数据集:

t = tf.constant([[1, 2], [3, 4]])ds = tf.data.Dataset.from_tensor_slices(t)   # [1, 2], [3, 4]


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5640244.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存