Start the data feeding thread. Can only call when the reader object is not iterable. Example: .. code-block:: pycon >>> import paddle >>> import paddle.base as base >>> import numpy as np >>> padd
(self)
| 1332 | return self._loader.__next__() |
| 1333 | |
| 1334 | def start(self): |
| 1335 | ''' |
| 1336 | Start the data feeding thread. |
| 1337 | Can only call when the reader object is not iterable. |
| 1338 | |
| 1339 | Example: |
| 1340 | .. code-block:: pycon |
| 1341 | |
| 1342 | >>> import paddle |
| 1343 | >>> import paddle.base as base |
| 1344 | >>> import numpy as np |
| 1345 | |
| 1346 | >>> paddle.enable_static() |
| 1347 | |
| 1348 | >>> BATCH_SIZE = 10 |
| 1349 | |
| 1350 | >>> def generator(): |
| 1351 | ... for i in range(5): |
| 1352 | ... yield (np.random.uniform(low=0, high=255, size=[784, 784]),) |
| 1353 | |
| 1354 | >>> image = paddle.static.data(name='image', shape=[None, 784, 784], dtype='float32') |
| 1355 | >>> reader = base.io.PyReader(feed_list=[image], capacity=4, iterable=False) |
| 1356 | >>> reader.decorate_sample_list_generator( |
| 1357 | ... paddle.batch(generator, batch_size=BATCH_SIZE), |
| 1358 | ... ) |
| 1359 | |
| 1360 | >>> executor = paddle.static.Executor(paddle.CPUPlace()) |
| 1361 | >>> executor.run(paddle.static.default_startup_program()) |
| 1362 | >>> for i in range(3): |
| 1363 | ... reader.start() |
| 1364 | ... while True: |
| 1365 | ... try: |
| 1366 | ... executor.run(feed=None) |
| 1367 | ... except base.core.EOFException: |
| 1368 | ... reader.reset() |
| 1369 | ... break |
| 1370 | ''' |
| 1371 | self._loader.start() |
| 1372 | |
| 1373 | def reset(self): |
| 1374 | ''' |
no outgoing calls