Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
47e2ef38
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
47e2ef38
编写于
7月 01, 2019
作者:
X
xsrobin
提交者:
GitHub
7月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add "import paddle.fluid as fluid" to examples lack of it
上级
92ecb305
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
378 addition
and
187 deletion
+378
-187
paddle/fluid/API.spec
paddle/fluid/API.spec
+179
-179
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+5
-0
python/paddle/fluid/average.py
python/paddle/fluid/average.py
+1
-0
python/paddle/fluid/backward.py
python/paddle/fluid/backward.py
+1
-0
python/paddle/fluid/data_feed_desc.py
python/paddle/fluid/data_feed_desc.py
+6
-0
python/paddle/fluid/executor.py
python/paddle/fluid/executor.py
+1
-0
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+9
-0
python/paddle/fluid/initializer.py
python/paddle/fluid/initializer.py
+13
-6
python/paddle/fluid/io.py
python/paddle/fluid/io.py
+8
-0
python/paddle/fluid/layers/control_flow.py
python/paddle/fluid/layers/control_flow.py
+8
-0
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+13
-0
python/paddle/fluid/layers/io.py
python/paddle/fluid/layers/io.py
+5
-0
python/paddle/fluid/layers/layer_function_generator.py
python/paddle/fluid/layers/layer_function_generator.py
+1
-0
python/paddle/fluid/layers/learning_rate_scheduler.py
python/paddle/fluid/layers/learning_rate_scheduler.py
+4
-1
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+90
-1
python/paddle/fluid/layers/ops.py
python/paddle/fluid/layers/ops.py
+3
-0
python/paddle/fluid/layers/tensor.py
python/paddle/fluid/layers/tensor.py
+13
-0
python/paddle/fluid/metrics.py
python/paddle/fluid/metrics.py
+8
-0
python/paddle/fluid/nets.py
python/paddle/fluid/nets.py
+2
-0
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+4
-0
python/paddle/fluid/profiler.py
python/paddle/fluid/profiler.py
+4
-0
未找到文件。
paddle/fluid/API.spec
浏览文件 @
47e2ef38
此差异已折叠。
点击以展开。
paddle/fluid/pybind/pybind.cc
浏览文件 @
47e2ef38
...
...
@@ -625,6 +625,7 @@ All parameter, weight, gradient are variables in Paddle.
Examples:
.. code-block:: python
import paddle.fluid as fluid
# create tensor from a scope and set value to it.
param = scope.var('Param').get_tensor()
param_array = np.full((height, row_numel), 5.0).astype("float32")
...
...
@@ -781,6 +782,7 @@ All parameter, weight, gradient are variables in Paddle.
Examples:
.. code-block:: python
import paddle.fluid as fluid
gpu_place = fluid.CUDAPlace(0)
)DOC"
)
...
...
@@ -839,6 +841,7 @@ All parameter, weight, gradient are variables in Paddle.
Examples:
.. code-block:: python
import paddle.fluid as fluid
cpu_place = fluid.CPUPlace()
)DOC"
)
...
...
@@ -858,6 +861,7 @@ All parameter, weight, gradient are variables in Paddle.
Examples:
.. code-block:: python
import paddle.fluid as fluid
place = fluid.CUDAPinnedPlace()
)DOC"
)
...
...
@@ -1156,6 +1160,7 @@ All parameter, weight, gradient are variables in Paddle.
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
y_predict = fluid.layers.fc(input=x, size=1, act=None)
...
...
python/paddle/fluid/average.py
浏览文件 @
47e2ef38
...
...
@@ -49,6 +49,7 @@ class WeightedAverage(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
avg = fluid.average.WeightedAverage()
avg.add(value=2.0, weight=1)
avg.add(value=4.0, weight=2)
...
...
python/paddle/fluid/backward.py
浏览文件 @
47e2ef38
...
...
@@ -489,6 +489,7 @@ def append_backward(loss, parameter_list=None, no_grad_set=None,
# network configuration code
# loss from ...
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[13], dtype='float32')
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
...
...
python/paddle/fluid/data_feed_desc.py
浏览文件 @
47e2ef38
...
...
@@ -31,6 +31,7 @@ class DataFeedDesc(object):
.. code-block:: python
import paddle.fluid as fluid
f = open("data.proto", "w")
print >> f, 'name: "MultiSlotDataFeed"'
print >> f, 'batch_size: 2'
...
...
@@ -61,6 +62,7 @@ class DataFeedDesc(object):
.. code-block:: python
import paddle.fluid as fluid
data_feed = fluid.DataFeedDesc('data.proto')
data_feed.set_batch_size(128)
data_feed.set_dense_slots('wd') # The slot named 'wd' will be dense
...
...
@@ -95,6 +97,7 @@ class DataFeedDesc(object):
Example:
.. code-block:: python
import paddle.fluid as fluid
f = open("data.proto", "w")
print >> f, 'name: "MultiSlotDataFeed"'
print >> f, 'batch_size: 2'
...
...
@@ -131,6 +134,7 @@ class DataFeedDesc(object):
Example:
.. code-block:: python
import paddle.fluid as fluid
f = open("data.proto", "w")
print >> f, 'name: "MultiSlotDataFeed"'
print >> f, 'batch_size: 2'
...
...
@@ -175,6 +179,7 @@ class DataFeedDesc(object):
Example:
.. code-block:: python
import paddle.fluid as fluid
f = open("data.proto", "w")
print >> f, 'name: "MultiSlotDataFeed"'
print >> f, 'batch_size: 2'
...
...
@@ -217,6 +222,7 @@ class DataFeedDesc(object):
Example:
.. code-block:: python
import paddle.fluid as fluid
f = open("data.proto", "w")
print >> f, 'name: "MultiSlotDataFeed"'
print >> f, 'batch_size: 2'
...
...
python/paddle/fluid/executor.py
浏览文件 @
47e2ef38
...
...
@@ -72,6 +72,7 @@ def scope_guard(scope):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy
new_scope = fluid.Scope()
...
...
python/paddle/fluid/framework.py
浏览文件 @
47e2ef38
...
...
@@ -67,6 +67,7 @@ def in_dygraph_mode():
Examples:
.. code-block:: python
import paddle.fluid as fluid
if fluid.in_dygraph_mode():
pass
...
...
@@ -143,6 +144,7 @@ def cuda_places(device_ids=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
cuda_places = fluid.cuda_places()
"""
...
...
@@ -173,6 +175,7 @@ def cpu_places(device_count=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
cpu_places = fluid.cpu_places()
"""
...
...
@@ -199,6 +202,7 @@ def cuda_pinned_places(device_count=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
cuda_pinned_places_cpu_num = fluid.cuda_pinned_places()
# or
cuda_pinned_places = fluid.cuda_pinned_places(1)
...
...
@@ -251,6 +255,7 @@ def name_scope(prefix=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
with fluid.name_scope("s1"):
a = fluid.layers.data(name='data', shape=[1], dtype='int32')
b = a + 1
...
...
@@ -412,6 +417,7 @@ class Variable(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
cur_program = Program()
cur_block = cur_program.current_block()
new_variable = cur_block.create_var(name="X",
...
...
@@ -1011,6 +1017,7 @@ class Operator(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
cur_program = Program()
cur_block = cur_program.current_block()
# var1 += var2 + var3
...
...
@@ -2918,6 +2925,7 @@ class Program(object):
Examples:
>>> import paddle.fluid as fluid
>>> p, g = backward(...)
>>> with program._optimized_guard([p,g]):
>>> p = p - 0.001 * g
...
...
@@ -2951,6 +2959,7 @@ class Program(object):
Examples:
>>> import paddle.fluid as fluid
>>> p, g = backward(...)
>>> with program.lr_schedule_guard():
>>> lr = lr * decay
...
...
python/paddle/fluid/initializer.py
浏览文件 @
47e2ef38
...
...
@@ -42,7 +42,8 @@ def force_init_on_cpu():
.. code-block:: python
if fluid.initializer.force_init_on_cpu():
import paddle.fluid as fluid
if fluid.initializer.force_init_on_cpu():
step = fluid.layers.create_global_var(
shape=[2,3], value=1.0, dtype='float32')
...
...
@@ -58,7 +59,8 @@ def init_on_cpu():
Examples:
.. code-block:: python
with fluid.initializer.init_on_cpu():
import paddle.fluid as fluid
with fluid.initializer.init_on_cpu():
step = fluid.layers.create_global_var(
shape=[2,3], value=1.0, dtype='float32')
...
...
@@ -133,7 +135,8 @@ class ConstantInitializer(Initializer):
Examples:
.. code-block:: python
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
import paddle.fluid as fluid
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
fc = fluid.layers.fc(input=x, size=10,
param_attr=fluid.initializer.Constant(value=2.0))
...
...
@@ -292,7 +295,8 @@ class NormalInitializer(Initializer):
Examples:
.. code-block:: python
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
import paddle.fluid as fluid
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
fc = fluid.layers.fc(input=x, size=10,
param_attr=fluid.initializer.Normal(loc=0.0, scale=2.0))
...
...
@@ -608,7 +612,8 @@ class MSRAInitializer(Initializer):
Examples:
.. code-block:: python
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
import paddle.fluid as fluid
x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
fc = fluid.layers.fc(input=x, size=10,
param_attr=fluid.initializer.MSRA(uniform=False))
...
...
@@ -710,7 +715,8 @@ class BilinearInitializer(Initializer):
.. code-block:: python
factor = 2
import paddle.fluid as fluid
factor = 2
C = 2
w_attr = fluid.param_attr.ParamAttr(
learning_rate=0.,
...
...
@@ -836,6 +842,7 @@ class NumpyArrayInitializer(Initializer):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[5], dtype='float32')
fc = fluid.layers.fc(input=x, size=10,
param_attr=fluid.initializer.NumpyArrayInitializer(numpy.array([1,2])))
...
...
python/paddle/fluid/io.py
浏览文件 @
47e2ef38
...
...
@@ -54,6 +54,7 @@ def is_parameter(var):
Examples:
.. code-block:: python
import paddle.fluid as fluid
param = fluid.default_main_program().global_block().var('fc.w')
res = fluid.io.is_parameter(param)
"""
...
...
@@ -74,6 +75,7 @@ def is_persistable(var):
Examples:
.. code-block:: python
import paddle.fluid as fluid
param = fluid.default_main_program().global_block().var('fc.b')
res = fluid.io.is_persistable(param)
"""
...
...
@@ -311,6 +313,7 @@ def _save_distributed_persistables(executor, dirname, main_program):
Examples:
.. code-block:: python
import paddle.fluid as fluid
exe = fluid.Executor(fluid.CPUPlace())
param_path = "./my_paddle_model"
t = distribute_transpiler.DistributeTranspiler()
...
...
@@ -693,6 +696,7 @@ def load_params(executor, dirname, main_program=None, filename=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
exe = fluid.Executor(fluid.CPUPlace())
param_path = "./my_paddle_model"
prog = fluid.default_main_program()
...
...
@@ -735,6 +739,7 @@ def load_persistables(executor, dirname, main_program=None, filename=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
exe = fluid.Executor(fluid.CPUPlace())
param_path = "./my_paddle_model"
prog = fluid.default_main_program()
...
...
@@ -772,6 +777,7 @@ def _load_distributed_persistables(executor, dirname, main_program=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
exe = fluid.Executor(fluid.CPUPlace())
param_path = "./my_paddle_model"
t = distribute_transpiler.DistributeTranspiler()
...
...
@@ -1242,6 +1248,7 @@ def get_parameter_value(para, executor):
Examples:
.. code-block:: python
import paddle.fluid as fluid
exe = fluid.Executor(fluid.CPUPlace())
param = fluid.default_main_program().global_block().var('fc.w')
p = fluid.io.get_parameter_value(param, exe)
...
...
@@ -1279,6 +1286,7 @@ def get_parameter_value_by_name(name, executor, program=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
exe = fluid.Executor(fluid.CPUPlace())
p = fluid.io.get_parameter_value('fc.w', exe)
"""
...
...
python/paddle/fluid/layers/control_flow.py
浏览文件 @
47e2ef38
...
...
@@ -58,6 +58,7 @@ def split_lod_tensor(input, mask, level=0):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[1])
x.persistable = True
...
...
@@ -107,6 +108,7 @@ def merge_lod_tensor(in_true, in_false, x, mask, level=0):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = layers.data(
name='x', shape=[1], dtype='float32', stop_gradient=False)
y = layers.data(
...
...
@@ -757,6 +759,7 @@ def lod_rank_table(x, level=0):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[10],
dtype='float32', lod_level=1)
out = layers.lod_rank_table(x=x, level=0)
...
...
@@ -823,6 +826,7 @@ def lod_tensor_to_array(x, table):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[10])
table = fluid.layers.lod_rank_table(x, level=0)
array = fluid.layers.lod_tensor_to_array(x, table)
...
...
@@ -856,6 +860,7 @@ def array_to_lod_tensor(x, table):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[10])
table = fluid.layers.lod_rank_table(x, level=0)
array = fluid.layers.lod_tensor_to_array(x, table)
...
...
@@ -965,6 +970,7 @@ def create_array(dtype):
Examples:
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.create_array(dtype='float32')
"""
...
...
@@ -992,6 +998,7 @@ def less_than(x, y, force_cpu=None, cond=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
label = fluid.layers.data(name='y', shape=[1], dtype='int64')
limit = fluid.layers.fill_constant(shape=[1], dtype='int64', value=5)
cond = fluid.layers.less_than(x=label, y=limit)
...
...
@@ -1357,6 +1364,7 @@ class ConditionalBlock(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
cond = layers.less_than(x=label, y=limit)
true_image, false_image = layers.split_lod_tensor(
input=image, mask=cond)
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
47e2ef38
...
...
@@ -680,6 +680,7 @@ def box_coder(prior_box,
.. code-block:: python
import paddle.fluid as fluid
prior_box = fluid.layers.data(name='prior_box',
shape=[512, 4],
dtype='float32',
...
...
@@ -811,6 +812,7 @@ def yolov3_loss(x,
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[255, 13, 13], dtype='float32')
gt_box = fluid.layers.data(name='gt_box', shape=[6, 4], dtype='float32')
gt_label = fluid.layers.data(name='gt_label', shape=[6], dtype='int32')
...
...
@@ -1001,6 +1003,7 @@ def detection_map(detect_res,
Examples:
.. code-block:: python
import paddle.fluid as fluid
from fluid.layers import detection
detect_res = fluid.layers.data(
name='detect_res',
...
...
@@ -1119,6 +1122,7 @@ def bipartite_match(dist_matrix,
Examples:
>>> import paddle.fluid as fluid
>>> x = fluid.layers.data(name='x', shape=[4], dtype='float32')
>>> y = fluid.layers.data(name='y', shape=[4], dtype='float32')
>>> iou = fluid.layers.iou_similarity(x=x, y=y)
...
...
@@ -1340,6 +1344,7 @@ def ssd_loss(location,
type of `max_negative`.
Examples:
>>> import paddle.fluid as fluid
>>> pb = fluid.layers.data(
>>> name='prior_box',
>>> shape=[10, 4],
...
...
@@ -1542,6 +1547,7 @@ def prior_box(input,
Examples:
.. code-block:: python
import paddle.fluid as fluid
input = fluid.layers.data(name="input", shape=[3,6,9])
images = fluid.layers.data(name="images", shape=[3,9,12])
box, var = fluid.layers.prior_box(
...
...
@@ -1668,6 +1674,7 @@ def density_prior_box(input,
Examples:
.. code-block:: python
import paddle.fluid as fluid
input = fluid.layers.data(name="input", shape=[3,6,9])
images = fluid.layers.data(name="images", shape=[3,9,12])
box, var = fluid.layers.density_prior_box(
...
...
@@ -2019,6 +2026,7 @@ def anchor_generator(input,
.. code-block:: python
import paddle.fluid as fluid
conv1 = fluid.layers.data(name='conv1', shape=[48, 16, 16], dtype='float32')
anchor, var = fluid.layers.anchor_generator(
input=conv1,
...
...
@@ -2525,6 +2533,7 @@ def box_clip(input, im_info, name=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
boxes = fluid.layers.data(
name='boxes', shape=[8, 4], dtype='float32', lod_level=1)
im_info = fluid.layers.data(name='im_info', shape=[3])
...
...
@@ -2729,6 +2738,7 @@ def multiclass_nms(bboxes,
.. code-block:: python
import paddle.fluid as fluid
boxes = fluid.layers.data(name='bboxes', shape=[81, 4],
dtype='float32', lod_level=1)
scores = fluid.layers.data(name='scores', shape=[81],
...
...
@@ -2807,6 +2817,7 @@ def distribute_fpn_proposals(fpn_rois,
Examples:
.. code-block:: python
import paddle.fluid as fluid
fpn_rois = fluid.layers.data(
name='data', shape=[4], dtype='float32', lod_level=1)
multi_rois, restore_ind = fluid.layers.distribute_fpn_proposals(
...
...
@@ -2865,6 +2876,7 @@ def box_decoder_and_assign(prior_box,
Examples:
.. code-block:: python
import paddle.fluid as fluid
pb = fluid.layers.data(
name='prior_box', shape=[4], dtype='float32')
pbv = fluid.layers.data(
...
...
@@ -2931,6 +2943,7 @@ def collect_fpn_proposals(multi_rois,
Examples:
.. code-block:: python
import paddle.fluid as fluid
multi_rois = []
multi_scores = []
for i in range(4):
...
...
python/paddle/fluid/layers/io.py
浏览文件 @
47e2ef38
...
...
@@ -84,6 +84,7 @@ def data(name,
Examples:
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.data(name='x', shape=[784], dtype='float32')
"""
helper
=
LayerHelper
(
'data'
,
**
locals
())
...
...
@@ -147,6 +148,7 @@ class ListenAndServ(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
with fluid.program_guard(main):
serv = layers.ListenAndServ(
"127.0.0.1:6170", ["X"], optimizer_mode=False)
...
...
@@ -449,6 +451,7 @@ def random_data_generator(low, high, shapes, lod_levels, for_parallel=True):
.. code-block:: python
import paddle.fluid as fluid
reader = fluid.layers.random_data_generator(
low=0.0,
high=1.0,
...
...
@@ -1017,6 +1020,7 @@ def shuffle(reader, buffer_size):
Examples:
.. code-block:: python
import paddle.fluid as fluid
raw_reader = fluid.layers.io.open_files(filenames=['./data1.recordio',
'./data2.recordio'],
shapes=[(3,224,224), (1,)],
...
...
@@ -1048,6 +1052,7 @@ def batch(reader, batch_size):
Examples:
.. code-block:: python
import paddle.fluid as fluid
raw_reader = fluid.layers.io.open_files(filenames=['./data1.recordio',
'./data2.recordio'],
shapes=[(3,224,224), (1,)],
...
...
python/paddle/fluid/layers/layer_function_generator.py
浏览文件 @
47e2ef38
...
...
@@ -253,6 +253,7 @@ def generate_activation_fn(op_type):
Examples:
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.data(name="input", shape=[32, 784])
result = fluid.layers.%s(data)
"""
%
op_type
...
...
python/paddle/fluid/layers/learning_rate_scheduler.py
浏览文件 @
47e2ef38
...
...
@@ -54,6 +54,7 @@ def noam_decay(d_model, warmup_steps):
.. code-block:: python
import padde.fluid as fluid
import numpy as np
# set hyper parameters
d_model = 2
...
...
@@ -415,7 +416,8 @@ def cosine_decay(learning_rate, step_each_epoch, epochs):
Examples:
.. code-block:: python
base_lr = 0.1
import paddle.fluid as fluid
base_lr = 0.1
lr = fluid.layers.cosine_decay(
learning_rate = base_lr, step_each_epoch=10000, epochs=120)
"""
...
...
@@ -457,6 +459,7 @@ def linear_lr_warmup(learning_rate, warmup_steps, start_lr, end_lr):
Examples:
.. code-block:: python
import paddle.fluid as fluid
boundaries = [100, 200]
lr_steps = [0.1, 0.01, 0.001]
warmup_steps = 50
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
47e2ef38
此差异已折叠。
点击以展开。
python/paddle/fluid/layers/ops.py
浏览文件 @
47e2ef38
...
...
@@ -114,6 +114,7 @@ def hard_shrink(x, threshold=None):
hard_shrink
.
__doc__
=
_hard_shrink_
.
__doc__
+
"""
Examples:
>>> import paddle.fluid as fluid
>>> data = fluid.layers.data(name="input", shape=[784])
>>> result = fluid.layers.hard_shrink(x=data, threshold=0.3)
"""
...
...
@@ -135,6 +136,7 @@ def cumsum(x, axis=None, exclusive=None, reverse=None):
cumsum
.
__doc__
=
_cum_sum_
.
__doc__
+
"""
Examples:
>>> import paddle.fluid as fluid
>>> data = fluid.layers.data(name="input", shape=[32, 784])
>>> result = fluid.layers.cumsum(data, axis=0)
"""
...
...
@@ -157,6 +159,7 @@ def thresholded_relu(x, threshold=None):
thresholded_relu
.
__doc__
=
_thresholded_relu_
.
__doc__
+
"""
Examples:
>>> import paddle.fluid as fluid
>>> data = fluid.layers.data(name="input", shape=[1])
>>> result = fluid.layers.thresholded_relu(data, threshold=0.4)
"""
python/paddle/fluid/layers/tensor.py
浏览文件 @
47e2ef38
...
...
@@ -49,6 +49,7 @@ def create_tensor(dtype, name=None, persistable=False):
Examples:
.. code-block:: python
import paddle.fluid as fluid
tensor = fluid.layers.create_tensor(dtype='float32')
"""
helper
=
LayerHelper
(
"create_tensor"
,
**
locals
())
...
...
@@ -85,6 +86,7 @@ def create_parameter(shape,
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
W = layers.create_parameter(shape=[784, 200], dtype='float32')
"""
...
...
@@ -123,6 +125,7 @@ def create_global_var(shape,
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
var = layers.create_global_var(shape=[2,3], value=1.0, dtype='float32',
persistable=True, force_cpu=True, name='new_var')
...
...
@@ -157,6 +160,7 @@ def cast(x, dtype):
Examples:
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.data(name='x', shape=[13], dtype='float32')
result = fluid.layers.cast(x=data, dtype='float64')
"""
...
...
@@ -190,6 +194,7 @@ def concat(input, axis=0, name=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
a = fluid.layers.data(name='a', shape=[2, 13], dtype='float32')
b = fluid.layers.data(name='b', shape=[2, 3], dtype='float32')
c = fluid.layers.data(name='c', shape=[2, 2], dtype='float32')
...
...
@@ -482,6 +487,7 @@ def argmin(x, axis=0):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[3, 4], dtype="float32")
out = fluid.layers.argmin(x, axis=0)
out = fluid.layers.argmin(x, axis=-1)
...
...
@@ -514,6 +520,7 @@ def argmax(x, axis=0):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[3, 4], dtype="float32")
out = fluid.layers.argmax(x, axis=0)
out = fluid.layers.argmax(x, axis=-1)
...
...
@@ -565,6 +572,7 @@ def argsort(input, axis=-1, name=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name="x", shape=[3, 4], dtype="float32")
out, indices = fluid.layers.argsort(input=x, axis=0)
"""
...
...
@@ -712,6 +720,7 @@ def save_combine(x, file_path, overwrite=True):
.. code-block:: python
import paddle.fluid as fluid
v1 = fluid.layers.data(name="data",
shape=(4, 6),
dtype="float32")
...
...
@@ -808,6 +817,7 @@ def isfinite(x):
.. code-block:: python
import paddle.fluid as fluid
var = fluid.layers.data(name="data",
shape=(4, 6),
dtype="float32")
...
...
@@ -843,6 +853,7 @@ def range(start, end, step, dtype):
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.range(0, 10, 2, 'int32')
"""
...
...
@@ -884,6 +895,7 @@ def linspace(start, stop, num, dtype):
Examples:
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.linspace(0, 10, 5, 'float32') # [0.0, 2.5, 5.0, 7.5, 10.0]
data = fluid.layers.linspace(0, 10, 1, 'float32') # [0.0]
...
...
@@ -925,6 +937,7 @@ def zeros_like(x, out=None):
Examples:
.. code-block:: python
import paddle.fluid as fluid
x = fluid.layers.data(name='x', dtype='float32', shape=[3], append_batch_size=False)
data = fluid.layers.zeros_like(x) # [0.0, 0.0, 0.0]
...
...
python/paddle/fluid/metrics.py
浏览文件 @
47e2ef38
...
...
@@ -154,6 +154,7 @@ class CompositeMetric(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
preds = [[0.1], [0.7], [0.8], [0.9], [0.2],
[0.2], [0.3], [0.5], [0.8], [0.6]]
...
...
@@ -226,6 +227,7 @@ class Precision(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
metric = fluid.metrics.Precision()
...
...
@@ -287,6 +289,7 @@ class Recall(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
metric = fluid.metrics.Recall()
...
...
@@ -346,6 +349,7 @@ class Accuracy(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
#suppose we have batch_size = 128
batch_size=128
accuracy_manager = fluid.metrics.Accuracy()
...
...
@@ -416,6 +420,7 @@ class ChunkEvaluator(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
# init the chunck-level evaluation manager
metric = fluid.metrics.ChunkEvaluator()
...
...
@@ -505,6 +510,7 @@ class EditDistance(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
# suppose that batch_size is 128
...
...
@@ -605,6 +611,7 @@ class Auc(MetricBase):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
# init the auc metric
auc_metric = fluid.metrics.Auc("ROC")
...
...
@@ -729,6 +736,7 @@ class DetectionMAP(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
batch_size = -1 # can be any size
...
...
python/paddle/fluid/nets.py
浏览文件 @
47e2ef38
...
...
@@ -190,6 +190,7 @@ def img_conv_group(input,
Examples:
.. code-block:: python
import paddle.fluid as fluid
img = fluid.layers.data(name='img', shape=[1, 28, 28], dtype='float32')
conv_pool = fluid.nets.img_conv_group(input=img,
conv_padding=1,
...
...
@@ -328,6 +329,7 @@ def glu(input, dim=-1):
Examples:
.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.data(
name="words", shape=[-1, 6, 3, 9], dtype="float32")
# shape of output: [-1, 3, 3, 9]
...
...
python/paddle/fluid/optimizer.py
浏览文件 @
47e2ef38
...
...
@@ -510,6 +510,7 @@ class Optimizer(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
loss = network()
optimizer = fluid.optimizer.SGD(learning_rate=0.1)
params_grads = optimizer.backward(loss)
...
...
@@ -827,6 +828,7 @@ class DGCMomentumOptimizer(MomentumOptimizer):
Examples:
.. code-block:: python
import paddle.fluid as fluid
optimizer = fluid.optimizer.DGCMomentumOptimizer(
learning_rate=0.0001,
momentum=0.9,
...
...
@@ -1699,6 +1701,7 @@ class AdadeltaOptimizer(Optimizer):
Examples:
.. code-block:: python
import paddle.fluid as fluid
optimizer = fluid.optimizer.Adadelta(
learning_rate=0.0003, epsilon=1.0e-6, rho=0.95)
_, params_grads = optimizer.minimize(cost)
...
...
@@ -2688,6 +2691,7 @@ class PipelineOptimizer(object):
Examples:
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
x = fluid.layers.data(name='x', shape=[1], dtype='int64', lod_level=0)
...
...
python/paddle/fluid/profiler.py
浏览文件 @
47e2ef38
...
...
@@ -113,6 +113,7 @@ def reset_profiler():
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.profiler as profiler
with profiler.profiler('CPU', 'total', '/tmp/profile'):
for iter in range(10):
...
...
@@ -141,6 +142,7 @@ def start_profiler(state):
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.profiler as profiler
profiler.start_profiler('GPU')
...
...
@@ -190,6 +192,7 @@ def stop_profiler(sorted_key=None, profile_path='/tmp/profile'):
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.profiler as profiler
profiler.start_profiler('GPU')
...
...
@@ -257,6 +260,7 @@ def profiler(state, sorted_key=None, profile_path='/tmp/profile'):
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.profiler as profiler
import numpy as np
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录