Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
fd41a87a
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fd41a87a
编写于
3月 04, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
complete data_type documentation
上级
3e398eaa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
114 addition
and
11 deletion
+114
-11
doc/api/index_en.rst
doc/api/index_en.rst
+9
-1
doc/api/v2/data.rst
doc/api/v2/data.rst
+6
-0
python/paddle/trainer/PyDataProvider2.py
python/paddle/trainer/PyDataProvider2.py
+89
-4
python/paddle/v2/data_type.py
python/paddle/v2/data_type.py
+10
-6
未找到文件。
doc/api/index_en.rst
浏览文件 @
fd41a87a
...
...
@@ -7,4 +7,12 @@ Model Config API
.. toctree::
:maxdepth: 1
v2/model_configs.rst
\ No newline at end of file
v2/model_configs.rst
Data API
--------
.. toctree::
:maxdepth: 1
v2/data.rst
doc/api/v2/data.rst
0 → 100644
浏览文件 @
fd41a87a
#########
DataTypes
#########
.. automodule:: paddle.v2.data_type
:members:
python/paddle/trainer/PyDataProvider2.py
浏览文件 @
fd41a87a
...
...
@@ -45,6 +45,23 @@ class CacheType(object):
class
InputType
(
object
):
"""
InputType is the base class for paddle input types.
.. note::
this is a base class, and should never be used by user.
:param dim: dimension of input. If the input is an integer, it means the
value range. Otherwise, it means the size of layer.
:type dim: int
:param seq_type: sequence type of input. 0 means it is not a sequence. 1
means it is a variable length sequence. 2 means it is a
nested sequence.
:type seq_type: int
:param type: data type of input.
:type type: int
"""
__slots__
=
[
'dim'
,
'seq_type'
,
'type'
]
def
__init__
(
self
,
dim
,
seq_type
,
tp
):
...
...
@@ -54,20 +71,61 @@ class InputType(object):
def
dense_slot
(
dim
,
seq_type
=
SequenceType
.
NO_SEQUENCE
):
"""
Dense Vector. It means the input feature is dense float vector. For example,
if the input is an image with 28*28 pixels, the input of Paddle neural
network should be a dense vector with dimension 784.
:param dim: dimension of this vector.
:type dim: int
:param seq_type: sequence type of input.
:type seq_type: int
:return: An input type object.
:rtype: InputType
"""
return
InputType
(
dim
,
seq_type
,
DataType
.
Dense
)
def
sparse_non_value_slot
(
dim
,
seq_type
=
SequenceType
.
NO_SEQUENCE
):
"""
Sparse binary vector. It means the input feature is a sparse vector and the
every element in this vector is either zero or one.
:param dim: dimension of this vector.
:type dim: int
:param seq_type: sequence type of this input.
:type seq_type: int
:return: An input type object.
:rtype: InputType
"""
return
InputType
(
dim
,
seq_type
,
DataType
.
SparseNonValue
)
def
sparse_value_slot
(
dim
,
seq_type
=
SequenceType
.
NO_SEQUENCE
):
"""
Sparse vector. It means the input feature is a sparse vector. Most of the
elements in this vector are zero, others could be any float value.
:param dim: dimension of this vector.
:type dim: int
:param seq_type: sequence type of this input.
:type seq_type: int
:return: An input type object.
:rtype: InputType
"""
return
InputType
(
dim
,
seq_type
,
DataType
.
SparseValue
)
def
index_slot
(
value_range
,
seq_type
=
SequenceType
.
NO_SEQUENCE
):
"""Data type of integer.
"""
Data type of integer.
:param seq_type: sequence type of this input.
:type seq_type: int
:param value_range: range of this integer.
:type value_range: int
:return: An input type object
:rtype: InputType
"""
return
InputType
(
value_range
,
seq_type
,
DataType
.
Index
)
...
...
@@ -76,10 +134,17 @@ dense_vector = dense_slot
sparse_binary_vector
=
sparse_non_value_slot
sparse_vector
=
sparse_value_slot
integer_value
=
index_slot
integer_value
.
__doc__
=
index_slot
.
__doc__
def
dense_vector_sequence
(
dim
):
"""
Data type of a sequence of dense vector.
:param dim: dimension of dense vector.
:type dim: int
:return: An input type object
:rtype: InputType
"""
return
dense_vector
(
dim
,
seq_type
=
SequenceType
.
SEQUENCE
)
...
...
@@ -88,6 +153,15 @@ def dense_vector_sub_sequence(dim):
def
sparse_binary_vector_sequence
(
dim
):
"""
Data type of a sequence of sparse vector, which every element is either zero
or one.
:param dim: dimension of sparse vector.
:type dim: int
:return: An input type object
:rtype: InputType
"""
return
sparse_binary_vector
(
dim
,
seq_type
=
SequenceType
.
SEQUENCE
)
...
...
@@ -96,6 +170,15 @@ def sparse_binary_vector_sub_sequence(dim):
def
sparse_vector_sequence
(
dim
):
"""
Data type of a sequence of sparse vector, which most elements are zero,
others could be any float value.
:param dim: dimension of sparse vector.
:type dim: int
:return: An input type object
:rtype: InputType
"""
return
sparse_vector
(
dim
,
seq_type
=
SequenceType
.
SEQUENCE
)
...
...
@@ -104,8 +187,11 @@ def sparse_vector_sub_sequence(dim):
def
integer_value_sequence
(
value_range
):
"""Data type of a sequence of integer.
"""
Data type of a sequence of integer.
:param value_range: range of each element.
:type value_range: int
"""
return
integer_value
(
value_range
,
seq_type
=
SequenceType
.
SEQUENCE
)
...
...
@@ -115,7 +201,6 @@ def integer_value_sub_sequence(dim):
integer_sequence
=
integer_value_sequence
integer_sequence
.
__doc__
=
integer_value_sequence
.
__doc__
class
SingleSlotWrapper
(
object
):
...
...
python/paddle/v2/data_type.py
浏览文件 @
fd41a87a
...
...
@@ -12,11 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle.trainer.PyDataProvider2
import
\
InputType
,
DataType
,
dense_vector
,
sparse_binary_vector
,
\
sparse_vector
,
integer_value
,
integer_value_sequence
import
paddle.trainer.PyDataProvider2
as
pydp2
__all__
=
[
'InputType'
,
'DataType'
,
'dense_vector'
,
'sparse_binary_vector'
,
'sparse_vector'
,
'integer_value'
,
'integer_value_sequence'
import_list
=
[
nm
for
nm
in
dir
(
pydp2
)
if
'_'
in
nm
and
nm
[
0
]
!=
'_'
and
(
'value'
in
nm
or
'vector'
in
nm
)
]
import_list
.
extend
([
'InputType'
])
for
nm
in
import_list
:
globals
()[
nm
]
=
getattr
(
pydp2
,
nm
)
__all__
=
import_list
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录