diff --git a/doc/paddle/api/paddle/io/buffered_cn.rst b/doc/paddle/api/paddle/io/buffered_cn.rst index 027c6346f735874d8c9accc38024c09b5940c429..626bda6f19eb4f5a42bff090a7016d8f818ce9f6 100644 --- a/doc/paddle/api/paddle/io/buffered_cn.rst +++ b/doc/paddle/api/paddle/io/buffered_cn.rst @@ -1,9 +1,9 @@ -.. _cn_api_fluid_io_buffered: +.. _cn_api_io_buffered: buffered ------------------------------- -.. py:function:: paddle.fluid.io.buffered(reader, size) +.. py:function:: paddle.io.buffered(reader, size) @@ -14,4 +14,21 @@ buffered - **reader** (callable) – 读取数据的reader - **size** (int) – 最大buffer的大小 -返回:缓存的reader(读取器) \ No newline at end of file +返回:缓存的reader(读取器) + +**代码示例** + +.. code-block:: python + + import paddle + + def reader(): + for i in range(3): + yield i + + # Create a buffered reader, and the buffer size is 2. + buffered_reader = paddle.io.buffered(reader, 2) + + # Output: 0 1 2 + for i in buffered_reader(): + print(i) diff --git a/doc/paddle/api/paddle/io/cache_cn.rst b/doc/paddle/api/paddle/io/cache_cn.rst index e93e4c85d134c0feb2ff813a6127c89816baed76..511bc9219168aeb95b14f5733e4961af401e3cb1 100644 --- a/doc/paddle/api/paddle/io/cache_cn.rst +++ b/doc/paddle/api/paddle/io/cache_cn.rst @@ -1,9 +1,9 @@ -.. _cn_api_fluid_io_cache: +.. _cn_api_io_cache: cache ------------------------------- -.. py:function:: paddle.fluid.io.cache(reader) +.. py:function:: paddle.io.cache(reader) @@ -15,4 +15,21 @@ cache 返回:每次都会从内存中yields数据的一个装饰reader。 -返回类型:生成器 \ No newline at end of file +返回类型:数据保存在内存的reader(读取器) + +**代码示例** + +.. code-block:: python + + import paddle + + def reader(): + for i in range(3): + yield i + + # All data is cached into memory + cached_reader = paddle.io.cache(reader) + + # Output: 0 1 2 + for i in cached_reader(): + print(i)