Skip to content

Commit fa79f48

Browse files
authored
Cherrypick1.5 (PaddlePaddle#1028)
* add 1.5.1 whl and fix some bugs (PaddlePaddle#1010) * add windows install whl * whl and bug * fix some bugs * update 1.5.1 cn API * add url
1 parent d5b5f41 commit fa79f48

20 files changed

+503
-212
lines changed

doc/fluid/api_cn/average_cn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ WeightedAverage
1919

2020
.. code-block:: python
2121
22+
import paddle.fluid as fluid
2223
avg = fluid.average.WeightedAverage()
2324
avg.add(value=2.0, weight=1)
2425
avg.add(value=4.0, weight=2)

doc/fluid/api_cn/backward_cn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ append_backward
3636
3737
# 网络配置
3838
# 损失计算
39+
import paddle.fluid as fluid
3940
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
4041
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
4142

doc/fluid/api_cn/data/data_reader_cn.rst

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ Data Reader Interface
238238
def reader():
239239
while True:
240240
yield numpy.random.uniform(-1, 1, size=width*height)
241-
return reader
241+
return reader
242242
243243
244244
多项目数据读取器创建者的示例实现:
@@ -249,7 +249,7 @@ Data Reader Interface
249249
def reader():
250250
while True:
251251
yield numpy.random.uniform(-1, 1, size=width*height), label
252-
return reader
252+
return reader
253253
254254
.. py:function:: paddle.reader.map_readers(func, *readers)
255255
@@ -292,7 +292,7 @@ Data Reader Interface
292292

293293
返回:新的数据读取器
294294

295-
抛出异常: ``ComposeNotAligned`` – reader的输出不一致。 当check_alignment设置为False,不会升高
295+
抛出异常: ``ComposeNotAligned`` – reader的输出不一致。 当check_alignment设置为False,不会抛出异常
296296

297297

298298

@@ -378,22 +378,15 @@ PipeReader通过流从一个命令中读取数据,将它的stdout放到管道
378378
379379
.. py:method:: get_line(cut_lines=True, line_break='\n')
380380
381-
param cut_lines:
382-
cut buffer to lines
383381
384-
type cut_lines: bool
385-
386-
param line_break:
387-
line break of the file, like
388-
389-
or
382+
参数:
383+
- **cut_lines** (bool) - 将缓冲区分行。
384+
- **line_break** (string) - 文件中的行分割符,比如 ‘\\n’ 或者 ‘\\r’。
390385

391-
type line_break:
392-
string
393386

394-
return: one line or a buffer of bytes
387+
返回:一行或者一段缓冲区。
395388

396-
rtype: string
389+
返回类型: string
397390

398391

399392

doc/fluid/api_cn/executor_cn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ scope_guard
267267

268268
.. code-block:: python
269269
270+
import paddle.fluid as fluid
270271
import numpy
271272
272273
new_scope = fluid.Scope()

doc/fluid/api_cn/fluid_cn.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ cpu_places
249249
250250
创建 ``fluid.CPUPlace`` 对象列表。
251251

252-
如果 ``device_count`` 为None,则设备数目将由环境变量 ``CPU_NUM`` 确定。如果未设置 ``CPU_NUM`` ,则设备数目将由 ``multiprocessing.cpu_count()`` 确定
252+
如果 ``device_count`` 为None,则设备数目将由环境变量 ``CPU_NUM`` 确定。如果未设置 ``CPU_NUM`` ,则设备数目默认为1,也就是说, ``CPU_NUM`` =1
253253

254254
参数:
255255
- **device_count** (None|int) - 设备数目
@@ -262,6 +262,7 @@ cpu_places
262262

263263
.. code-block:: python
264264
265+
import paddle.fluid as fluid
265266
cpu_places = fluid.cpu_places()
266267
267268
@@ -279,6 +280,7 @@ CPUPlace是设备的描述符。它代表一个CPU,可以访问CPUPlace对应
279280

280281
.. code-block:: python
281282
283+
import paddle.fluid as fluid
282284
cpu_place = fluid.CPUPlace()
283285
284286
@@ -397,6 +399,7 @@ cuda_pinned_places
397399

398400
.. code-block:: python
399401
402+
import paddle.fluid as fluid
400403
cuda_pinned_places_cpu_num = fluid.cuda_pinned_places()
401404
# 或者
402405
cuda_pinned_places = fluid.cuda_pinned_places(1)
@@ -428,6 +431,7 @@ cuda_places
428431

429432
.. code-block:: python
430433
434+
import paddle.fluid as fluid
431435
cuda_places = fluid.cuda_places()
432436
433437
.. _cn_api_fluid_CUDAPinnedPlace:
@@ -443,6 +447,7 @@ CUDAPinnedPlace是一个设备描述符,它所指代的存储空间可以被GP
443447

444448
.. code-block:: python
445449
450+
import paddle.fluid as fluid
446451
place = fluid.CUDAPinnedPlace()
447452
448453
.. _cn_api_fluid_CUDAPlace:
@@ -458,6 +463,7 @@ CUDAPlace是一个设备描述符,它代表一个GPU,并且每个CUDAPlace
458463

459464
.. code-block:: python
460465
466+
import paddle.fluid as fluid
461467
gpu_place = fluid.CUDAPlace(0)
462468
463469
@@ -482,6 +488,7 @@ DataFeedDesc应由来自磁盘的有效protobuf消息初始化。
482488

483489
.. code-block:: python
484490
491+
import paddle.fluid as fluid
485492
f = open("data.proto", "w")
486493
print >> f, 'name: "MultiSlotDataFeed"'
487494
print >> f, 'batch_size: 2'
@@ -508,6 +515,7 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含
508515

509516
.. code-block:: python
510517
518+
import paddle.fluid as fluid
511519
data_feed = fluid.DataFeedDesc('data.proto')
512520
data_feed.set_batch_size(128)
513521
data_feed.set_dense_slots('wd') # 名为'wd'的slot将被设置为密集的
@@ -534,6 +542,7 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含
534542

535543
.. code-block:: python
536544
545+
import paddle.fluid as fluid
537546
f = open("data.proto", "w")
538547
print >> f, 'name: "MultiSlotDataFeed"'
539548
print >> f, 'batch_size: 2'
@@ -569,6 +578,7 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含
569578

570579
.. code-block:: python
571580
581+
import paddle.fluid as fluid
572582
f = open("data.proto", "w")
573583
print >> f, 'name: "MultiSlotDataFeed"'
574584
print >> f, 'batch_size: 2'
@@ -606,6 +616,7 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含
606616

607617
.. code-block:: python
608618
619+
import paddle.fluid as fluid
609620
f = open("data.proto", "w")
610621
print >> f, 'name: "MultiSlotDataFeed"'
611622
print >> f, 'batch_size: 2'
@@ -642,6 +653,7 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含
642653

643654
.. code-block:: python
644655
656+
import paddle.fluid as fluid
645657
f = open("data.proto", "w")
646658
print >> f, 'name: "MultiSlotDataFeed"'
647659
print >> f, 'batch_size: 2'
@@ -993,6 +1005,7 @@ DistributeTranspiler
9931005

9941006
.. code-block:: python
9951007
1008+
import paddle.fluid as fluid
9961009
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
9971010
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
9981011
y_predict = fluid.layers.fc(input=x, size=1, act=None)
@@ -1053,6 +1066,7 @@ DistributeTranspiler
10531066
10541067
.. code-block:: python
10551068
1069+
import paddle.fluid as fluid
10561070
transpiler = fluid.DistributeTranspiler()
10571071
t.transpile(
10581072
trainer_id=0,
@@ -1162,6 +1176,7 @@ DistributeTranspiler
11621176
11631177
.. code-block:: python
11641178
1179+
import paddle.fluid as fluid
11651180
pserver_endpoints = "192.168.0.1:6174,192.168.0.2:6174"
11661181
trainer_endpoints = "192.168.0.1:6174,192.168.0.2:6174"
11671182
current_endpoint = "192.168.0.1:6174"
@@ -1207,6 +1222,7 @@ block中分割(split)出的元素个数的最小值。
12071222
12081223
.. code-block:: python
12091224
1225+
import paddle.fluid as fluid
12101226
config = fluid.DistributeTranspilerConfig()
12111227
config.slice_var_up = True
12121228
@@ -1226,6 +1242,7 @@ ExecutionStrategy
12261242
12271243
.. code-block:: python
12281244
1245+
import paddle.fluid as fluid
12291246
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
12301247
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
12311248
y_predict = fluid.layers.fc(input=x, size=1, act=None)
@@ -1578,6 +1595,7 @@ in_dygraph_mode
15781595

15791596
.. code-block:: python
15801597
1598+
import paddle.fluid as fluid
15811599
if fluid.in_dygraph_mode():
15821600
pass
15831601
@@ -1875,6 +1893,7 @@ name_scope
18751893

18761894
.. code-block:: python
18771895
1896+
import paddle.fluid as fluid
18781897
with fluid.name_scope("s1"):
18791898
a = fluid.layers.data(name='data', shape=[1], dtype='int32')
18801899
b = a + 1
@@ -2043,6 +2062,7 @@ ParallelExecutor
20432062

20442063
.. code-block:: python
20452064
2065+
import paddle.fluid as fluid
20462066
pe = fluid.ParallelExecutor(use_cuda=use_cuda,
20472067
loss_name=avg_cost.name,
20482068
main_program=fluid.default_main_program())
@@ -2211,6 +2231,7 @@ Program
22112231

22122232
.. code-block:: python
22132233
2234+
import paddle.fluid as fluid
22142235
test_program = fluid.default_main_program().clone(for_test=True)
22152236
optimizer = fluid.optimizer.Momentum(learning_rate=0.01, momentum=0.9)
22162237
optimizer.minimize()
@@ -2538,6 +2559,7 @@ scope_guard
25382559

25392560
.. code-block:: python
25402561
2562+
import paddle.fluid as fluid
25412563
import numpy
25422564
25432565
new_scope = fluid.Scope()

doc/fluid/api_cn/initializer_cn.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ BilinearInitializer
2626

2727
.. code-block:: python
2828
29+
import paddle.fluid as fluid
2930
factor = 2
3031
C = 2
3132
w_attr = fluid.initializer.ParamAttr(
@@ -77,6 +78,7 @@ ConstantInitializer
7778

7879
.. code-block:: python
7980
81+
import paddle.fluid as fluid
8082
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
8183
fc = fluid.layers.fc(input=x, size=10,
8284
param_attr=fluid.initializer.Constant(value=2.0))
@@ -104,6 +106,7 @@ force_init_on_cpu
104106

105107
.. code-block:: python
106108
109+
import paddle.fluid as fluid
107110
if fluid.initializer.force_init_on_cpu():
108111
step = fluid.layers.create_global_var(shape=[2,3], value=1.0, dtype='float32')
109112
@@ -130,6 +133,7 @@ init_on_cpu
130133

131134
.. code-block:: python
132135
136+
import paddle.fluid as fluid
133137
with fluid.initializer.init_on_cpu():
134138
step = fluid.layers.create_global_var(shape=[2,3], value=1.0, dtype='float32')
135139
@@ -183,6 +187,7 @@ MSRAInitializer
183187

184188
.. code-block:: python
185189
190+
import paddle.fluid as fluid
186191
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
187192
fc = fluid.layers.fc(input=x, size=10, param_attr=fluid.initializer.MSRA(uniform=False))
188193
@@ -219,6 +224,7 @@ NormalInitializer
219224

220225
.. code-block:: python
221226
227+
import paddle.fluid as fluid
222228
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
223229
fc = fluid.layers.fc(input=x, size=10,
224230
param_attr=fluid.initializer.Normal(loc=0.0, scale=2.0)
@@ -240,6 +246,7 @@ NumpyArrayInitializer
240246
241247
.. code-block:: python
242248
249+
import paddle.fluid as fluid
243250
x = fluid.layers.data(name="x", shape=[5], dtype='float32')
244251
fc = fluid.layers.fc(input=x, size=10,
245252
param_attr=fluid.initializer.NumpyArrayInitializer(numpy.array([1,2])))

doc/fluid/api_cn/io_cn.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ load_params
9696

9797
.. code-block:: python
9898
99+
import paddle.fluid as fluid
99100
exe = fluid.Executor(fluid.CPUPlace())
100101
param_path = "./my_paddle_model"
101102
prog = fluid.default_main_program()
@@ -131,6 +132,7 @@ load_persistables
131132

132133
.. code-block:: python
133134
135+
import paddle.fluid as fluid
134136
exe = fluid.Executor(fluid.CPUPlace())
135137
param_path = "./my_paddle_model"
136138
prog = fluid.default_main_program()
@@ -237,6 +239,7 @@ PyReader
237239
238240
.. code-block:: python
239241
242+
import paddle.fluid as fluid
240243
EPOCH_NUM = 3
241244
ITER_NUM = 5
242245
BATCH_SIZE = 3
@@ -278,6 +281,7 @@ PyReader
278281

279282
.. code-block:: python
280283
284+
import paddle.fluid as fluid
281285
EPOCH_NUM = 3
282286
ITER_NUM = 5
283287
BATCH_SIZE = 10
@@ -346,6 +350,7 @@ PyReader
346350

347351
.. code-block:: python
348352
353+
import paddle.fluid as fluid
349354
BATCH_SIZE = 10
350355
351356
def generator():
@@ -376,6 +381,7 @@ PyReader
376381

377382
.. code-block:: python
378383
384+
import paddle.fluid as fluid
379385
BATCH_SIZE = 10
380386
381387
def generator():
@@ -418,6 +424,7 @@ PyReader
418424

419425
.. code-block:: python
420426
427+
import paddle.fluid as fluid
421428
EPOCH_NUM = 3
422429
ITER_NUM = 15
423430
BATCH_SIZE = 3
@@ -464,6 +471,7 @@ PyReader
464471

465472
.. code-block:: python
466473
474+
import paddle.fluid as fluid
467475
EPOCH_NUM = 3
468476
ITER_NUM = 15
469477
BATCH_SIZE = 3
@@ -510,6 +518,7 @@ PyReader
510518

511519
.. code-block:: python
512520
521+
import paddle.fluid as fluid
513522
EPOCH_NUM = 3
514523
ITER_NUM = 15
515524
BATCH_SIZE = 3
@@ -636,6 +645,7 @@ save_params
636645

637646
.. code-block:: python
638647
648+
import paddle.fluid as fluid
639649
exe = fluid.Executor(fluid.CPUPlace())
640650
param_path = "./my_paddle_model"
641651
prog = fluid.default_main_program()

0 commit comments

Comments
 (0)