Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
527b22f2
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
527b22f2
编写于
6月 19, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'doc_framework' of
https://github.com/JiayiFeng/Paddle
into doc_framework
上级
49f23e63
6046ab57
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
62 addition
and
20 deletion
+62
-20
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+62
-20
未找到文件。
python/paddle/fluid/framework.py
浏览文件 @
527b22f2
...
@@ -120,37 +120,55 @@ def _debug_string_(proto, throw_on_error=True):
...
@@ -120,37 +120,55 @@ def _debug_string_(proto, throw_on_error=True):
class
Variable
(
object
):
class
Variable
(
object
):
"""
"""
Python variable. Every input and output of an operator is a variable. Every
In Fluid, every input and output of an operator is a variable. In most
variable belongs to a block. The variable has a name and two variables in
cases, variables are used for holding different kinds of data or training
different blocks could have the same name.
labels. A variable belongs to a block. All variable has its own name and
two variables in different blocks could have the same name.
There are many kinds of variables. Please reference the framework.proto for
There are many kinds of variables. Each kind of them has its own attributes
details.
and usages. Please reference the framework.proto for details.
Most of a Variable's member variables can be setted to be None. It mean
it is not avaiable or will be specified later.
Notes: The constructor of Variable should not be invoked directly. Please
Notes: The constructor of Variable should not be invoked directly. Please
use `Block.create_var` to create a variable.
use `Block.create_var` to create a variable.
>>> cur_program = Program()
.. code-block:: python
>>> cur_block = cur_program.current_block()
cur_program = Program()
>>> new_variable = cur_block.create_var(
cur_block = cur_program.current_block()
>>> name="X", shape=[-1, 23, 48], dtype='float32')
new_variable = cur_block.create_var(
name="X", shape=[-1, 23, 48], dtype='float32')
Args:
Member variables:
block(Block): The associated block. It will be passed by
block(Block): The block that the variable belongs to.
`Block.create_var` automatically.
type(core.VarDesc.VarType): Variable type. Please reference the
type(core.VarDesc.VarType): Variable type. Please reference the
framework.proto for details.
framework.proto for details.
shape(tuple|list|None): The shape of variable. -1 means the batch size.
name(str|None): The name of the variable. If setted None, it will be
generated automatically.
Default: None
shape(tuple|list|None): The shape of the variable. -1 means the batch size.
Some kinds of variable do not contain shape, just set it to None.
Some kinds of variable do not contain shape, just set it to None.
dtype(np.dtype|core.VarDesc.VarType|str): The data type of variable.
Default: None
lod_level(int): The level of lod tensor. 0 means it is not a time
dtype(np.dtype|core.VarDesc.VarType|str|None): The data type of variable.
Default: None
lod_level(int|None): The level of lod tensor. 0 means it is not a time
series data.
series data.
capacity(int): The capacity of Channel variable. Ignored
Default: None
capacity(int|None): The capacity of Channel variable. Ignored
for other types.
for other types.
persistable(bool): True if the variable should be saved as check point.
Default: None
Defaults to False.
persistable(bool|None): True if the variable is persistable. A persistable
stop_gradient(bool): True if the variable will stop to calculate
variable will not be deleted after an iteration ending.
gradients when backward. Defaults to False.
Defaults: None.
error_clip(BaseErrorClipAttr|None): The error clip attributes of the
corresponding gradient variable.
Default: None
stop_gradient(bool): True if the variable will stop to calculate its
gradients when backward.
Default: False.
is_data(bool): True is the variable is an input data.
Default: False
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
...
@@ -1306,6 +1324,30 @@ class Program(object):
...
@@ -1306,6 +1324,30 @@ class Program(object):
class
Parameter
(
Variable
):
class
Parameter
(
Variable
):
"""
Parameter is derived from Variable. A parameter is a persistable
Variable, and will be updated by optimizers after each iteration.
The training of a neural network is essentially the updating of
its parameters.
Relative to a general Vriable, a Parameter has several its own
member variables:
trainable(bool): True if the parameter need to be updated after
iterations.
optimize_attr(map): Parameter attributes related with optimizing.
Currently, it only contains 'learning_rate'.
Default: {'learning_rate': 1.0}
regularizer(WeightDecayRegularizer): The Regularizer which will
be applied on the parameter.
Default: None
gradient_clip_attr(BaseGradientClipAttr): The gradint clip strategy
which will be applied on the parameter.
Default: None
do_model_average(bool): True if the model average strategy will
be applied on this parameter.
"""
def
__init__
(
self
,
block
,
shape
,
dtype
,
**
kwargs
):
def
__init__
(
self
,
block
,
shape
,
dtype
,
**
kwargs
):
if
shape
is
None
or
dtype
is
None
:
if
shape
is
None
or
dtype
is
None
:
raise
ValueError
(
"Parameter must set shape and dtype"
)
raise
ValueError
(
"Parameter must set shape and dtype"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录