创建dataset的方法
1,几种方法
Create a source dataset using one of the factory functions like Dataset.from_tensors
, Dataset.from_tensor_slices
or using objects that read from files like TextLineDataset
or TFRecordDataset
2,自数组
ds_tensors = tf.data.Dataset.from_tensor_slices([1, 2, 3, 4, 5, 6])
3,自文件
# Create a CSV file
import tempfile
_, filename = tempfile.mkstemp()
with open(filename, 'w') as f:
f.write("""Line 1
Line 2
Line 3
""")
ds_file = tf.data.TextLineDataset(filename)