未验证 提交 0aedd463 编写于 作者: M mls1999725 提交者: GitHub

Update get_worker_info API (#29190)

* Update get_worker_info API

* Update dataloader_iter.py

* Update dataloader_iter.py

* Update dataloader_iter.py
上级 c59b4f28
...@@ -153,8 +153,8 @@ def get_worker_info(): ...@@ -153,8 +153,8 @@ def get_worker_info():
.. code-block:: python .. code-block:: python
import math import math
import paddle
import numpy as np import numpy as np
import paddle.fluid as fluid
from paddle.io import IterableDataset, DataLoader, get_worker_info from paddle.io import IterableDataset, DataLoader, get_worker_info
class SplitedIterableDataset(IterableDataset): class SplitedIterableDataset(IterableDataset):
...@@ -178,18 +178,18 @@ def get_worker_info(): ...@@ -178,18 +178,18 @@ def get_worker_info():
for i in range(iter_start, iter_end): for i in range(iter_start, iter_end):
yield np.array([i]) yield np.array([i])
place = fluid.CPUPlace() place = paddle.CPUPlace()
with fluid.dygraph.guard(place): dataset = SplitedIterableDataset(start=2, end=9)
dataset = SplitedIterableDataset(start=2, end=9) dataloader = DataLoader(
dataloader = DataLoader( dataset,
dataset, places=place,
places=place, num_workers=2,
num_workers=2, batch_size=1,
batch_size=1, drop_last=True)
drop_last=True)
for data in dataloader:
print(list(dataloader)) print(data)
# outputs: [2, 5, 3, 6, 4, 7] # outputs: [2, 5, 3, 6, 4, 7]
""" """
return _worker_info return _worker_info
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册