Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
772b476b
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看板
提交
772b476b
编写于
2月 20, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize code
上级
3b69629d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
18 deletion
+14
-18
demo/mnist/api_train.py
demo/mnist/api_train.py
+2
-2
demo/mnist/api_train_v2.py
demo/mnist/api_train_v2.py
+2
-2
python/paddle/v2/layer.py
python/paddle/v2/layer.py
+10
-14
未找到文件。
demo/mnist/api_train.py
浏览文件 @
772b476b
...
@@ -71,8 +71,8 @@ def main():
...
@@ -71,8 +71,8 @@ def main():
assert
isinstance
(
updater
,
api
.
ParameterUpdater
)
assert
isinstance
(
updater
,
api
.
ParameterUpdater
)
# define network
# define network
images
=
paddle_v2
.
layer
.
data
(
name
=
'pixel'
,
type
=
dp
.
dense_vector
(
784
))
images
=
paddle_v2
.
layer
.
data
(
name
=
'pixel'
,
data_
type
=
dp
.
dense_vector
(
784
))
label
=
paddle_v2
.
layer
.
data
(
name
=
'label'
,
type
=
dp
.
integer_value
(
10
))
label
=
paddle_v2
.
layer
.
data
(
name
=
'label'
,
data_
type
=
dp
.
integer_value
(
10
))
hidden1
=
paddle_v2
.
layer
.
fc
(
input
=
images
,
size
=
200
)
hidden1
=
paddle_v2
.
layer
.
fc
(
input
=
images
,
size
=
200
)
hidden2
=
paddle_v2
.
layer
.
fc
(
input
=
hidden1
,
size
=
200
)
hidden2
=
paddle_v2
.
layer
.
fc
(
input
=
hidden1
,
size
=
200
)
inference
=
paddle_v2
.
layer
.
fc
(
input
=
hidden2
,
inference
=
paddle_v2
.
layer
.
fc
(
input
=
hidden2
,
...
...
demo/mnist/api_train_v2.py
浏览文件 @
772b476b
...
@@ -16,8 +16,8 @@ def main():
...
@@ -16,8 +16,8 @@ def main():
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
paddle
.
init
(
use_gpu
=
False
,
trainer_count
=
1
)
# define network topology
# define network topology
images
=
paddle
.
layer
.
data
(
name
=
'pixel'
,
type
=
dense_vector
(
784
))
images
=
paddle
.
layer
.
data
(
name
=
'pixel'
,
data_
type
=
dense_vector
(
784
))
label
=
paddle
.
layer
.
data
(
name
=
'label'
,
type
=
integer_value
(
10
))
label
=
paddle
.
layer
.
data
(
name
=
'label'
,
data_
type
=
integer_value
(
10
))
hidden1
=
paddle
.
layer
.
fc
(
input
=
images
,
size
=
200
)
hidden1
=
paddle
.
layer
.
fc
(
input
=
images
,
size
=
200
)
hidden2
=
paddle
.
layer
.
fc
(
input
=
hidden1
,
size
=
200
)
hidden2
=
paddle
.
layer
.
fc
(
input
=
hidden1
,
size
=
200
)
inference
=
paddle
.
layer
.
fc
(
input
=
hidden2
,
inference
=
paddle
.
layer
.
fc
(
input
=
hidden2
,
...
...
python/paddle/v2/layer.py
浏览文件 @
772b476b
...
@@ -165,26 +165,22 @@ So we also need to implement some special LayerV2.
...
@@ -165,26 +165,22 @@ So we also need to implement some special LayerV2.
class
DataLayerV2
(
Layer
):
class
DataLayerV2
(
Layer
):
def
__init__
(
self
,
name
,
type
,
**
kwargs
):
def
__init__
(
self
,
name
,
data_type
,
**
kwargs
):
self
.
__method_name__
=
'data_layer'
assert
isinstance
(
data_type
,
dp
.
InputType
)
assert
isinstance
(
type
,
dp
.
InputType
)
# get data_size from type.dim
self
.
__method_name__
=
'data_layer'
args
=
dict
()
self
.
__kwargs__
=
kwargs
for
key
in
kwargs
:
self
.
__data_size__
=
data_type
.
dim
args
[
key
]
=
kwargs
[
key
]
args
[
'size'
]
=
type
.
dim
self
.
__args__
=
args
super
(
DataLayerV2
,
self
).
__init__
(
name
=
name
,
parent_layers
=
dict
())
super
(
DataLayerV2
,
self
).
__init__
(
name
=
name
,
parent_layers
=
dict
())
def
to_proto_impl
(
self
,
**
kwargs
):
def
to_proto_impl
(
self
,
**
kwargs
):
args
=
dict
()
args
=
dict
()
args
[
'size'
]
=
self
.
__data_size__
for
each
in
kwargs
:
for
each
in
kwargs
:
args
[
each
]
=
kwargs
[
each
]
args
[
each
]
=
kwargs
[
each
]
for
each
in
self
.
__args__
:
for
each
in
self
.
__
kw
args__
:
args
[
each
]
=
self
.
__args__
[
each
]
args
[
each
]
=
self
.
__
kw
args__
[
each
]
return
getattr
(
conf_helps
,
self
.
__method_name__
)(
name
=
self
.
name
,
**
args
)
return
getattr
(
conf_helps
,
self
.
__method_name__
)(
name
=
self
.
name
,
**
args
)
...
@@ -202,8 +198,8 @@ cross_entropy_cost = __convert_to_v2__(
...
@@ -202,8 +198,8 @@ cross_entropy_cost = __convert_to_v2__(
parent_names
=
[
'input'
,
'label'
])
parent_names
=
[
'input'
,
'label'
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
pixel
=
data
(
name
=
'pixel'
,
type
=
dp
.
dense_vector
(
784
))
pixel
=
data
(
name
=
'pixel'
,
data_
type
=
dp
.
dense_vector
(
784
))
label
=
data
(
name
=
'label'
,
type
=
dp
.
integer_value
(
10
))
label
=
data
(
name
=
'label'
,
data_
type
=
dp
.
integer_value
(
10
))
hidden
=
fc
(
input
=
pixel
,
size
=
100
,
act
=
conf_helps
.
SigmoidActivation
())
hidden
=
fc
(
input
=
pixel
,
size
=
100
,
act
=
conf_helps
.
SigmoidActivation
())
inference
=
fc
(
input
=
hidden
,
size
=
10
,
act
=
conf_helps
.
SoftmaxActivation
())
inference
=
fc
(
input
=
hidden
,
size
=
10
,
act
=
conf_helps
.
SoftmaxActivation
())
maxid
=
max_id
(
input
=
inference
)
maxid
=
max_id
(
input
=
inference
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录