Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
42df377e
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
42df377e
编写于
8月 28, 2018
作者:
G
guochaorong
提交者:
GitHub
8月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1195 from guochaorong/mnist_python3
support python3 for mnist
上级
a8307be1
1e8e846d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
7 deletion
+7
-7
fluid/mnist/model.py
fluid/mnist/model.py
+7
-7
未找到文件。
fluid/mnist/model.py
浏览文件 @
42df377e
...
@@ -9,6 +9,7 @@ import time
...
@@ -9,6 +9,7 @@ import time
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.fluid.profiler
as
profiler
import
paddle.fluid.profiler
as
profiler
import
six
SEED
=
90
SEED
=
90
DTYPE
=
"float32"
DTYPE
=
"float32"
...
@@ -47,7 +48,7 @@ def print_arguments(args):
...
@@ -47,7 +48,7 @@ def print_arguments(args):
vars
(
args
)[
'use_nvprof'
]
=
(
vars
(
args
)[
'use_nvprof'
]
and
vars
(
args
)[
'use_nvprof'
]
=
(
vars
(
args
)[
'use_nvprof'
]
and
vars
(
args
)[
'device'
]
==
'GPU'
)
vars
(
args
)[
'device'
]
==
'GPU'
)
print
(
'----------- Configuration Arguments -----------'
)
print
(
'----------- Configuration Arguments -----------'
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
(
)):
for
arg
,
value
in
sorted
(
six
.
iteritems
(
vars
(
args
)
)):
print
(
'%s: %s'
%
(
arg
,
value
))
print
(
'%s: %s'
%
(
arg
,
value
))
print
(
'------------------------------------------------'
)
print
(
'------------------------------------------------'
)
...
@@ -71,7 +72,7 @@ def cnn_model(data):
...
@@ -71,7 +72,7 @@ def cnn_model(data):
# TODO(dzhwinter) : refine the initializer and random seed settting
# TODO(dzhwinter) : refine the initializer and random seed settting
SIZE
=
10
SIZE
=
10
input_shape
=
conv_pool_2
.
shape
input_shape
=
conv_pool_2
.
shape
param_shape
=
[
reduce
(
lambda
a
,
b
:
a
*
b
,
input_shape
[
1
:],
1
)]
+
[
SIZE
]
param_shape
=
[
six
.
moves
.
reduce
(
lambda
a
,
b
:
a
*
b
,
input_shape
[
1
:],
1
)]
+
[
SIZE
]
scale
=
(
2.0
/
(
param_shape
[
0
]
**
2
*
SIZE
))
**
0.5
scale
=
(
2.0
/
(
param_shape
[
0
]
**
2
*
SIZE
))
**
0.5
predict
=
fluid
.
layers
.
fc
(
predict
=
fluid
.
layers
.
fc
(
...
@@ -89,9 +90,8 @@ def eval_test(exe, batch_acc, batch_size_tensor, inference_program):
...
@@ -89,9 +90,8 @@ def eval_test(exe, batch_acc, batch_size_tensor, inference_program):
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
args
.
batch_size
)
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
args
.
batch_size
)
test_pass_acc
=
fluid
.
average
.
WeightedAverage
()
test_pass_acc
=
fluid
.
average
.
WeightedAverage
()
for
batch_id
,
data
in
enumerate
(
test_reader
()):
for
batch_id
,
data
in
enumerate
(
test_reader
()):
img_data
=
np
.
array
(
map
(
lambda
x
:
x
[
0
].
reshape
([
1
,
28
,
28
]),
img_data
=
np
.
array
([
x
[
0
].
reshape
([
1
,
28
,
28
])
for
x
in
data
]).
astype
(
DTYPE
)
data
)).
astype
(
DTYPE
)
y_data
=
np
.
array
([
x
[
1
]
for
x
in
data
]).
astype
(
"int64"
)
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)).
astype
(
"int64"
)
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
acc
,
weight
=
exe
.
run
(
inference_program
,
acc
,
weight
=
exe
.
run
(
inference_program
,
...
@@ -153,8 +153,8 @@ def run_benchmark(model, args):
...
@@ -153,8 +153,8 @@ def run_benchmark(model, args):
every_pass_loss
=
[]
every_pass_loss
=
[]
for
batch_id
,
data
in
enumerate
(
train_reader
()):
for
batch_id
,
data
in
enumerate
(
train_reader
()):
img_data
=
np
.
array
(
img_data
=
np
.
array
(
map
(
lambda
x
:
x
[
0
].
reshape
([
1
,
28
,
28
]),
data
)
).
astype
(
DTYPE
)
[
x
[
0
].
reshape
([
1
,
28
,
28
])
for
x
in
data
]
).
astype
(
DTYPE
)
y_data
=
np
.
array
(
map
(
lambda
x
:
x
[
1
],
data
)
).
astype
(
"int64"
)
y_data
=
np
.
array
(
[
x
[
1
]
for
x
in
data
]
).
astype
(
"int64"
)
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
y_data
=
y_data
.
reshape
([
len
(
y_data
),
1
])
start
=
time
.
time
()
start
=
time
.
time
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录