Split a dataset created by Tensorflow dataset API in to Train and Test?

前端 未结 8 750
天命终不由人
天命终不由人 2020-12-08 02:12

Does anyone know how to split a dataset created by the dataset API (tf.data.Dataset) in Tensorflow into Test and Train?

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 02:52

    You can use shard:

    dataset = dataset.shuffle()  # optional
    trainset = dataset.shard(2, 0)
    testset = dataset.shard(2, 1)
    

    See: https://www.tensorflow.org/api_docs/python/tf/data/Dataset#shard

提交回复
热议问题