当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tf.compat.v1.data.TFRecordDataset.concatenate用法及代码示例


用法

concatenate(
    dataset, name=None
)

参数

  • dataset Dataset 被连接。
  • name (可选。) tf.data 操作的名称。

返回

  • Dataset 一个Dataset

通过将给定数据集与此数据集连接来创建 Dataset

a = tf.data.Dataset.range(1, 4)  # ==> [ 1, 2, 3 ]
b = tf.data.Dataset.range(4, 8)  # ==> [ 4, 5, 6, 7 ]
ds = a.concatenate(b)
list(ds.as_numpy_iterator())
[1, 2, 3, 4, 5, 6, 7]
# The input dataset and dataset to be concatenated should have
# compatible element specs.
c = tf.data.Dataset.zip((a, b))
a.concatenate(c)
Traceback (most recent call last):
TypeError:Two datasets to concatenate have different types
<dtype:'int64'> and (tf.int64, tf.int64)
d = tf.data.Dataset.from_tensor_slices(["a", "b", "c"])
a.concatenate(d)
Traceback (most recent call last):
TypeError:Two datasets to concatenate have different types
<dtype:'int64'> and <dtype:'string'>

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.data.TFRecordDataset.concatenate。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。