向 tf.data 服務注冊數據集。
用法
tf.data.experimental.service.register_dataset(
service, dataset, compression='AUTO'
)參數
-
service指示如何連接到 tf.data 服務的字符串或元組。如果它是一個字符串,它應該采用[<protocol>://]<address>格式,其中<address>標識調度程序地址,並且可以選擇使用<protocol>來覆蓋要使用的默認協議。如果它是一個元組,它應該是(協議,地址)。 -
datasetAtf.data.Dataset用於注冊 tf.data 服務。 -
compression(可選。)如何在通過網絡傳輸數據集元素之前對其進行壓縮。 "AUTO" 將如何壓縮的決定留給 tf.data 服務運行時。None表示不壓縮。
返回
- 已注冊數據集 id 的標量 int64 張量。
register_dataset 向 tf.data 服務注冊數據集,以便以後可以使用 tf.data.experimental.service.from_dataset_id 創建數據集。當數據集由一個進程注冊,然後在另一個進程中使用時,這很有用。當同一個進程同時注冊和讀取數據集時,使用 tf.data.experimental.service.distribute 會更簡單。
如果數據集已經注冊到 tf.data 服務,register_dataset 返回已經注冊的數據集的 id。
dispatcher = tf.data.experimental.service.DispatchServer()
dispatcher_address = dispatcher.target.split("://")[1]
worker = tf.data.experimental.service.WorkerServer(
tf.data.experimental.service.WorkerConfig(
dispatcher_address=dispatcher_address))
dataset = tf.data.Dataset.range(10)
dataset_id = tf.data.experimental.service.register_dataset(
dispatcher.target, dataset)
dataset = tf.data.experimental.service.from_dataset_id(
processing_mode="parallel_epochs",
service=dispatcher.target,
dataset_id=dataset_id,
element_spec=dataset.element_spec)
print(list(dataset.as_numpy_iterator()))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
相關用法
- Python tf.data.experimental.service.DispatchServer用法及代碼示例
- Python tf.data.experimental.service.from_dataset_id用法及代碼示例
- Python tf.data.experimental.service.DispatchServer.start用法及代碼示例
- Python tf.data.experimental.service.DispatchServer.join用法及代碼示例
- Python tf.data.experimental.service.WorkerServer.join用法及代碼示例
- Python tf.data.experimental.service.WorkerServer用法及代碼示例
- Python tf.data.experimental.service.distribute用法及代碼示例
- Python tf.data.experimental.save用法及代碼示例
- Python tf.data.experimental.snapshot用法及代碼示例
- Python tf.data.experimental.shuffle_and_repeat用法及代碼示例
- Python tf.data.experimental.sample_from_datasets用法及代碼示例
- Python tf.data.experimental.RandomDataset.group_by_window用法及代碼示例
- Python tf.data.experimental.SqlDataset.enumerate用法及代碼示例
- Python tf.data.experimental.make_saveable_from_iterator用法及代碼示例
- Python tf.data.experimental.SqlDataset.zip用法及代碼示例
- Python tf.data.experimental.Counter用法及代碼示例
- Python tf.data.experimental.SqlDataset.shard用法及代碼示例
- Python tf.data.experimental.CsvDataset.window用法及代碼示例
- Python tf.data.experimental.RandomDataset.cache用法及代碼示例
- Python tf.data.experimental.SqlDataset.snapshot用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.data.experimental.service.register_dataset。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
