Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
59adf7ce
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
59adf7ce
编写于
8月 09, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix round(0.0) special issue
上级
938a9e4f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
20 addition
and
11 deletion
+20
-11
python/paddle/fluid/compat.py
python/paddle/fluid/compat.py
+3
-1
python/paddle/fluid/debugger.py
python/paddle/fluid/debugger.py
+1
-0
python/paddle/fluid/graphviz.py
python/paddle/fluid/graphviz.py
+1
-0
python/paddle/fluid/profiler.py
python/paddle/fluid/profiler.py
+2
-1
python/paddle/fluid/tests/unittests/test_compat.py
python/paddle/fluid/tests/unittests/test_compat.py
+2
-0
python/paddle/fluid/tests/unittests/test_conv_shift_op.py
python/paddle/fluid/tests/unittests/test_conv_shift_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_gru_op.py
python/paddle/fluid/tests/unittests/test_gru_op.py
+2
-1
python/paddle/fluid/tests/unittests/test_inference_model_io.py
...n/paddle/fluid/tests/unittests/test_inference_model_io.py
+3
-2
python/paddle/fluid/tests/unittests/test_pool_max_op.py
python/paddle/fluid/tests/unittests/test_pool_max_op.py
+5
-5
未找到文件。
python/paddle/fluid/compat.py
浏览文件 @
59adf7ce
...
...
@@ -183,9 +183,11 @@ def round(x, d=0):
if
x
>
0.0
:
p
=
10
**
d
return
float
(
math
.
floor
((
x
*
p
)
+
math
.
copysign
(
0.5
,
x
)))
/
p
el
se
:
el
if
x
<
0.0
:
p
=
10
**
d
return
float
(
math
.
ceil
((
x
*
p
)
+
math
.
copysign
(
0.5
,
x
)))
/
p
else
:
return
math
.
copysign
(
0.0
,
x
)
else
:
import
__builtin__
return
__builtin__
.
round
(
x
,
d
)
...
...
python/paddle/fluid/debugger.py
浏览文件 @
59adf7ce
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
import
sys
import
six
import
re
from
.graphviz
import
GraphPreviewGenerator
from
.proto
import
framework_pb2
...
...
python/paddle/fluid/graphviz.py
浏览文件 @
59adf7ce
...
...
@@ -15,6 +15,7 @@
import
os
import
random
import
six
import
functools
import
subprocess
import
logging
...
...
python/paddle/fluid/profiler.py
浏览文件 @
59adf7ce
...
...
@@ -15,6 +15,7 @@
from
.
import
core
from
contextlib
import
contextmanager
import
os
import
six
__all__
=
[
'cuda_profiler'
,
'reset_profiler'
,
'profiler'
,
'start_profiler'
,
...
...
@@ -88,7 +89,7 @@ def cuda_profiler(output_file, output_mode=None, config=None):
config
=
NVPROF_CONFIG
if
config
is
None
else
config
config_file
=
'nvprof_config_file'
with
open
(
config_file
,
'wb'
)
as
fp
:
fp
.
writelines
([
"%s
\n
"
%
item
for
item
in
config
])
fp
.
writelines
([
six
.
b
(
"%s
\n
"
%
item
)
for
item
in
config
])
core
.
nvprof_init
(
output_file
,
output_mode
,
config_file
)
# Enables profiler collection by the active CUDA profiling tool.
core
.
nvprof_start
()
...
...
python/paddle/fluid/tests/unittests/test_compat.py
浏览文件 @
59adf7ce
...
...
@@ -440,6 +440,8 @@ class TestCompatible(unittest.TestCase):
self
.
assertEqual
(
3.0
,
cpt
.
round
(
3.4
))
self
.
assertEqual
(
4.0
,
cpt
.
round
(
3.5
))
self
.
assertEqual
(
0.0
,
cpt
.
round
(
0.1
))
self
.
assertEqual
(
0.0
,
cpt
.
round
(
0.0
))
self
.
assertEqual
(
-
0.0
,
cpt
.
round
(
-
0.0
))
self
.
assertEqual
(
-
0.0
,
cpt
.
round
(
-
0.1
))
self
.
assertEqual
(
-
3.0
,
cpt
.
round
(
-
3.4
))
self
.
assertEqual
(
-
4.0
,
cpt
.
round
(
-
3.5
))
...
...
python/paddle/fluid/tests/unittests/test_conv_shift_op.py
浏览文件 @
59adf7ce
...
...
@@ -21,7 +21,7 @@ def conv_shift_forward(x, y):
out
=
np
.
zeros_like
(
x
)
M
=
x
.
shape
[
1
]
N
=
y
.
shape
[
1
]
y_half_width
=
(
N
-
1
)
/
2
y_half_width
=
(
N
-
1
)
/
/
2
for
i
in
range
(
M
):
for
j
in
range
(
N
):
out
[:,
i
]
+=
x
[:,
(
i
+
j
+
M
-
y_half_width
)
%
M
]
*
y
[:,
j
]
...
...
python/paddle/fluid/tests/unittests/test_gru_op.py
浏览文件 @
59adf7ce
...
...
@@ -15,6 +15,7 @@
import
unittest
import
numpy
as
np
import
math
import
functools
from
op_test
import
OpTest
from
test_lstm_op
import
identity
,
sigmoid
,
tanh
,
relu
...
...
@@ -38,7 +39,7 @@ class TestGRUOp(OpTest):
for
i
in
range
(
len
(
seq_lens
)):
seq_starts
.
append
(
seq_starts
[
-
1
]
+
seq_lens
[
i
])
sorted_seqs
=
sorted
(
list
(
range
(
len
(
seq_lens
))),
lambda
x
,
y
:
seq_lens
[
y
]
-
seq_lens
[
x
]
)
list
(
range
(
len
(
seq_lens
))),
key
=
functools
.
cmp_to_key
(
lambda
x
,
y
:
seq_lens
[
y
]
-
seq_lens
[
x
])
)
num_batch
=
seq_lens
[
sorted_seqs
[
0
]]
for
batch_idx
in
range
(
num_batch
):
idx_in_seq
=
[]
...
...
python/paddle/fluid/tests/unittests/test_inference_model_io.py
浏览文件 @
59adf7ce
...
...
@@ -14,6 +14,7 @@
import
unittest
import
six
import
numpy
as
np
import
paddle.fluid.core
as
core
...
...
@@ -48,7 +49,7 @@ class TestBook(unittest.TestCase):
exe
.
run
(
init_program
,
feed
=
{},
fetch_list
=
[])
for
i
in
range
(
100
):
for
i
in
six
.
moves
.
x
range
(
100
):
tensor_x
=
np
.
array
(
[[
1
,
1
],
[
1
,
2
],
[
3
,
4
],
[
5
,
2
]]).
astype
(
"float32"
)
tensor_y
=
np
.
array
([[
-
2
],
[
-
3
],
[
-
7
],
[
-
7
]]).
astype
(
"float32"
)
...
...
@@ -64,7 +65,7 @@ class TestBook(unittest.TestCase):
'y'
:
tensor_y
},
fetch_list
=
[
avg_cost
])[
0
]
reload
(
executor
)
# reload to build a new scope
six
.
moves
.
reload_module
(
executor
)
# reload to build a new scope
exe
=
executor
.
Executor
(
place
)
[
infer_prog
,
feed_var_names
,
fetch_vars
]
=
load_inference_model
(
...
...
python/paddle/fluid/tests/unittests/test_pool_max_op.py
浏览文件 @
59adf7ce
...
...
@@ -24,9 +24,9 @@ def max_pool3D_forward_naive(x, ksize, strides, paddings, global_pool=False):
ksize
=
[
D
,
H
,
W
]
paddings
=
[
0
,
0
,
0
]
D_out
=
(
D
-
ksize
[
0
]
+
2
*
paddings
[
0
])
/
strides
[
0
]
+
1
H_out
=
(
H
-
ksize
[
1
]
+
2
*
paddings
[
1
])
/
strides
[
1
]
+
1
W_out
=
(
W
-
ksize
[
2
]
+
2
*
paddings
[
2
])
/
strides
[
2
]
+
1
D_out
=
(
D
-
ksize
[
0
]
+
2
*
paddings
[
0
])
/
/
strides
[
0
]
+
1
H_out
=
(
H
-
ksize
[
1
]
+
2
*
paddings
[
1
])
/
/
strides
[
1
]
+
1
W_out
=
(
W
-
ksize
[
2
]
+
2
*
paddings
[
2
])
/
/
strides
[
2
]
+
1
out
=
np
.
zeros
((
N
,
C
,
D_out
,
H_out
,
W_out
))
mask
=
np
.
zeros
((
N
,
C
,
D_out
,
H_out
,
W_out
))
for
k
in
range
(
D_out
):
...
...
@@ -63,8 +63,8 @@ def max_pool2D_forward_naive(x, ksize, strides, paddings, global_pool=False):
ksize
=
[
H
,
W
]
paddings
=
[
0
,
0
]
H_out
=
(
H
-
ksize
[
0
]
+
2
*
paddings
[
0
])
/
strides
[
0
]
+
1
W_out
=
(
W
-
ksize
[
1
]
+
2
*
paddings
[
1
])
/
strides
[
1
]
+
1
H_out
=
(
H
-
ksize
[
0
]
+
2
*
paddings
[
0
])
/
/
strides
[
0
]
+
1
W_out
=
(
W
-
ksize
[
1
]
+
2
*
paddings
[
1
])
/
/
strides
[
1
]
+
1
out
=
np
.
zeros
((
N
,
C
,
H_out
,
W_out
))
mask
=
np
.
zeros
((
N
,
C
,
H_out
,
W_out
))
for
i
in
range
(
H_out
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录