Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
984d54d0
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
984d54d0
编写于
2月 20, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change data_type to type
上级
89cfb39f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
18 deletion
+41
-18
demo/mnist/api_train.py
demo/mnist/api_train.py
+5
-5
demo/mnist/api_train_v2.py
demo/mnist/api_train_v2.py
+4
-5
python/paddle/v2/__init__.py
python/paddle/v2/__init__.py
+3
-1
python/paddle/v2/data.py
python/paddle/v2/data.py
+22
-0
python/paddle/v2/layer.py
python/paddle/v2/layer.py
+7
-7
未找到文件。
demo/mnist/api_train.py
浏览文件 @
984d54d0
...
...
@@ -9,7 +9,6 @@ The user api could be simpler and carefully designed.
import
random
import
numpy
as
np
import
paddle.trainer.PyDataProvider2
as
dp
import
paddle.v2
as
paddle_v2
import
py_paddle.swig_paddle
as
api
from
paddle.trainer_config_helpers
import
*
...
...
@@ -71,8 +70,10 @@ def main():
assert
isinstance
(
updater
,
api
.
ParameterUpdater
)
# define network
images
=
paddle_v2
.
layer
.
data
(
name
=
'pixel'
,
data_type
=
dp
.
dense_vector
(
784
))
label
=
paddle_v2
.
layer
.
data
(
name
=
'label'
,
data_type
=
dp
.
integer_value
(
10
))
images
=
paddle_v2
.
layer
.
data
(
name
=
'pixel'
,
type
=
paddle_v2
.
data
.
dense_vector
(
784
))
label
=
paddle_v2
.
layer
.
data
(
name
=
'label'
,
type
=
paddle_v2
.
data
.
integer_value
(
10
))
hidden1
=
paddle_v2
.
layer
.
fc
(
input
=
images
,
size
=
200
)
hidden2
=
paddle_v2
.
layer
.
fc
(
input
=
hidden1
,
size
=
200
)
inference
=
paddle_v2
.
layer
.
fc
(
input
=
hidden2
,
...
...
@@ -98,8 +99,7 @@ def main():
# DataProvider Converter is a utility convert Python Object to Paddle C++
# Input. The input format is as same as Paddle's DataProvider.
converter
=
DataProviderConverter
(
input_types
=
[
images
.
data_type
,
label
.
data_type
])
converter
=
DataProviderConverter
(
input_types
=
[
images
.
type
,
label
.
type
])
train_file
=
'./data/raw_data/train'
test_file
=
'./data/raw_data/t10k'
...
...
demo/mnist/api_train_v2.py
浏览文件 @
984d54d0
import
numpy
import
paddle.v2
as
paddle
from
paddle.trainer.PyDataProvider2
import
dense_vector
,
integer_value
import
mnist_util
...
...
@@ -16,8 +15,8 @@ def main():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
# define network topology
images
=
paddle
.
layer
.
data
(
name
=
'pixel'
,
data_type
=
dense_vector
(
784
))
label
=
paddle
.
layer
.
data
(
name
=
'label'
,
data_type
=
integer_value
(
10
))
images
=
paddle
.
layer
.
data
(
name
=
'pixel'
,
type
=
paddle
.
data
.
dense_vector
(
784
))
label
=
paddle
.
layer
.
data
(
name
=
'label'
,
type
=
paddle
.
data
.
integer_value
(
10
))
hidden1
=
paddle
.
layer
.
fc
(
input
=
images
,
size
=
200
)
hidden2
=
paddle
.
layer
.
fc
(
input
=
hidden1
,
size
=
200
)
inference
=
paddle
.
layer
.
fc
(
input
=
hidden2
,
...
...
@@ -51,8 +50,8 @@ def main():
batch_size
=
32
,
# batch size should be refactor in Data reader
data_types
=
{
# data_types will be removed, It should be in
# network topology
'pixel'
:
images
.
data_
type
,
'label'
:
label
.
data_
type
'pixel'
:
images
.
type
,
'label'
:
label
.
type
})
...
...
python/paddle/v2/__init__.py
浏览文件 @
984d54d0
...
...
@@ -17,10 +17,12 @@ import activation
import
parameters
import
trainer
import
event
import
data
import
py_paddle.swig_paddle
as
api
__all__
=
[
'optimizer'
,
'layer'
,
'activation'
,
'parameters'
,
'init'
,
'trainer'
,
'event'
'optimizer'
,
'layer'
,
'activation'
,
'parameters'
,
'init'
,
'trainer'
,
'event'
,
'data'
]
...
...
python/paddle/v2/data.py
0 → 100644
浏览文件 @
984d54d0
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle.trainer.PyDataProvider2
import
\
InputType
,
dense_vector
,
sparse_binary_vector
,
\
sparse_vector
,
integer_value
__all__
=
[
'InputType'
,
'dense_vector'
,
'sparse_binary_vector'
,
'sparse_vector'
,
'integer_value'
]
python/paddle/v2/layer.py
浏览文件 @
984d54d0
...
...
@@ -67,7 +67,7 @@ paddle.v2.parameters.create, no longer exposed to users.
"""
import
paddle.trainer_config_helpers
as
conf_helps
import
paddle.trainer.PyDataProvider2
as
dp
from
.
import
data
as
v2_data
from
paddle.trainer_config_helpers.config_parser_utils
import
\
parse_network_config
as
__parse__
from
paddle.trainer_config_helpers.default_decorators
import
wrap_name_default
...
...
@@ -165,10 +165,10 @@ So we also need to implement some special LayerV2.
class
DataLayerV2
(
Layer
):
def
__init__
(
self
,
name
,
data_
type
,
**
kwargs
):
assert
isinstance
(
data_type
,
dp
.
InputType
)
def
__init__
(
self
,
name
,
type
,
**
kwargs
):
assert
isinstance
(
type
,
v2_data
.
InputType
)
self
.
data_type
=
data_
type
self
.
type
=
type
self
.
__method_name__
=
'data_layer'
self
.
__kwargs__
=
kwargs
...
...
@@ -176,7 +176,7 @@ class DataLayerV2(Layer):
def
to_proto_impl
(
self
,
**
kwargs
):
args
=
dict
()
args
[
'size'
]
=
self
.
data_
type
.
dim
args
[
'size'
]
=
self
.
type
.
dim
for
each
in
kwargs
:
args
[
each
]
=
kwargs
[
each
]
for
each
in
self
.
__kwargs__
:
...
...
@@ -198,8 +198,8 @@ cross_entropy_cost = __convert_to_v2__(
parent_names
=
[
'input'
,
'label'
])
if
__name__
==
'__main__'
:
pixel
=
data
(
name
=
'pixel'
,
data_type
=
dp
.
dense_vector
(
784
))
label
=
data
(
name
=
'label'
,
data_type
=
dp
.
integer_value
(
10
))
pixel
=
data
(
name
=
'pixel'
,
type
=
v2_data
.
dense_vector
(
784
))
label
=
data
(
name
=
'label'
,
type
=
v2_data
.
integer_value
(
10
))
hidden
=
fc
(
input
=
pixel
,
size
=
100
,
act
=
conf_helps
.
SigmoidActivation
())
inference
=
fc
(
input
=
hidden
,
size
=
10
,
act
=
conf_helps
.
SoftmaxActivation
())
maxid
=
max_id
(
input
=
inference
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录