Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1f618c4f
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看板
提交
1f618c4f
编写于
8月 06, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the overfix of 2to3 in xrange
上级
5656f64b
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
55 addition
and
37 deletion
+55
-37
python/paddle/dataset/conll05.py
python/paddle/dataset/conll05.py
+1
-1
python/paddle/dataset/imdb.py
python/paddle/dataset/imdb.py
+2
-1
python/paddle/dataset/imikolov.py
python/paddle/dataset/imikolov.py
+3
-2
python/paddle/dataset/mnist.py
python/paddle/dataset/mnist.py
+1
-0
python/paddle/dataset/tests/common_test.py
python/paddle/dataset/tests/common_test.py
+1
-0
python/paddle/dataset/uci_housing.py
python/paddle/dataset/uci_housing.py
+3
-2
python/paddle/fluid/executor.py
python/paddle/fluid/executor.py
+1
-1
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+12
-6
python/paddle/fluid/layer_helper.py
python/paddle/fluid/layer_helper.py
+1
-1
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+14
-13
python/paddle/fluid/layers/io.py
python/paddle/fluid/layers/io.py
+4
-3
python/paddle/fluid/nets.py
python/paddle/fluid/nets.py
+2
-1
python/paddle/fluid/parallel_executor.py
python/paddle/fluid/parallel_executor.py
+3
-2
python/paddle/fluid/tests/demo/pyreader.py
python/paddle/fluid/tests/demo/pyreader.py
+3
-2
python/paddle/fluid/tests/unittests/dist_transformer.py
python/paddle/fluid/tests/unittests/dist_transformer.py
+2
-1
python/paddle/fluid/tests/unittests/test_split_ids_op.py
python/paddle/fluid/tests/unittests/test_split_ids_op.py
+2
-1
未找到文件。
python/paddle/dataset/conll05.py
浏览文件 @
1f618c4f
...
@@ -24,7 +24,7 @@ import tarfile
...
@@ -24,7 +24,7 @@ import tarfile
import
gzip
import
gzip
import
itertools
import
itertools
import
paddle.dataset.common
import
paddle.dataset.common
from
six.moves
import
zip
from
six.moves
import
zip
,
range
__all__
=
[
'test, get_dict'
,
'get_embedding'
,
'convert'
]
__all__
=
[
'test, get_dict'
,
'get_embedding'
,
'convert'
]
...
...
python/paddle/dataset/imdb.py
浏览文件 @
1f618c4f
...
@@ -25,6 +25,7 @@ import collections
...
@@ -25,6 +25,7 @@ import collections
import
tarfile
import
tarfile
import
re
import
re
import
string
import
string
from
six.moves
import
range
__all__
=
[
'build_dict'
,
'train'
,
'test'
,
'convert'
]
__all__
=
[
'build_dict'
,
'train'
,
'test'
,
'convert'
]
...
@@ -66,7 +67,7 @@ def build_dict(pattern, cutoff):
...
@@ -66,7 +67,7 @@ def build_dict(pattern, cutoff):
dictionary
=
sorted
(
word_freq
,
key
=
lambda
x
:
(
-
x
[
1
],
x
[
0
]))
dictionary
=
sorted
(
word_freq
,
key
=
lambda
x
:
(
-
x
[
1
],
x
[
0
]))
words
,
_
=
list
(
zip
(
*
dictionary
))
words
,
_
=
list
(
zip
(
*
dictionary
))
word_idx
=
dict
(
list
(
zip
(
words
,
list
(
range
(
len
(
words
)
)))))
word_idx
=
dict
(
list
(
zip
(
words
,
range
(
len
(
words
)))))
word_idx
[
'<unk>'
]
=
len
(
words
)
word_idx
[
'<unk>'
]
=
len
(
words
)
return
word_idx
return
word_idx
...
...
python/paddle/dataset/imikolov.py
浏览文件 @
1f618c4f
...
@@ -14,13 +14,14 @@
...
@@ -14,13 +14,14 @@
"""
"""
imikolov's simple dataset.
imikolov's simple dataset.
This module will download dataset from
This module will download dataset from
http://www.fit.vutbr.cz/~imikolov/rnnlm/ and parse training set and test set
http://www.fit.vutbr.cz/~imikolov/rnnlm/ and parse training set and test set
into paddle reader creators.
into paddle reader creators.
"""
"""
import
paddle.dataset.common
import
paddle.dataset.common
import
collections
import
collections
import
tarfile
import
tarfile
from
six.moves
import
range
__all__
=
[
'train'
,
'test'
,
'build_dict'
,
'convert'
]
__all__
=
[
'train'
,
'test'
,
'build_dict'
,
'convert'
]
...
@@ -68,7 +69,7 @@ def build_dict(min_word_freq=50):
...
@@ -68,7 +69,7 @@ def build_dict(min_word_freq=50):
word_freq_sorted
=
sorted
(
word_freq
,
key
=
lambda
x
:
(
-
x
[
1
],
x
[
0
]))
word_freq_sorted
=
sorted
(
word_freq
,
key
=
lambda
x
:
(
-
x
[
1
],
x
[
0
]))
words
,
_
=
list
(
zip
(
*
word_freq_sorted
))
words
,
_
=
list
(
zip
(
*
word_freq_sorted
))
word_idx
=
dict
(
list
(
zip
(
words
,
list
(
range
(
len
(
words
)
)))))
word_idx
=
dict
(
list
(
zip
(
words
,
range
(
len
(
words
)))))
word_idx
[
'<unk>'
]
=
len
(
words
)
word_idx
[
'<unk>'
]
=
len
(
words
)
return
word_idx
return
word_idx
...
...
python/paddle/dataset/mnist.py
浏览文件 @
1f618c4f
...
@@ -21,6 +21,7 @@ import paddle.dataset.common
...
@@ -21,6 +21,7 @@ import paddle.dataset.common
import
subprocess
import
subprocess
import
numpy
import
numpy
import
platform
import
platform
from
six.moves
import
range
__all__
=
[
'train'
,
'test'
,
'convert'
]
__all__
=
[
'train'
,
'test'
,
'convert'
]
URL_PREFIX
=
'http://yann.lecun.com/exdb/mnist/'
URL_PREFIX
=
'http://yann.lecun.com/exdb/mnist/'
...
...
python/paddle/dataset/tests/common_test.py
浏览文件 @
1f618c4f
...
@@ -16,6 +16,7 @@ import paddle.dataset.common
...
@@ -16,6 +16,7 @@ import paddle.dataset.common
import
unittest
import
unittest
import
tempfile
import
tempfile
import
glob
import
glob
from
six.moves
import
range
class
TestCommon
(
unittest
.
TestCase
):
class
TestCommon
(
unittest
.
TestCase
):
...
...
python/paddle/dataset/uci_housing.py
浏览文件 @
1f618c4f
...
@@ -22,6 +22,7 @@ parse training set and test set into paddle reader creators.
...
@@ -22,6 +22,7 @@ parse training set and test set into paddle reader creators.
import
os
import
os
import
numpy
as
np
import
numpy
as
np
import
six
import
tempfile
import
tempfile
import
tarfile
import
tarfile
import
os
import
os
...
@@ -74,7 +75,7 @@ def load_data(filename, feature_num=14, ratio=0.8):
...
@@ -74,7 +75,7 @@ def load_data(filename, feature_num=14, ratio=0.8):
maximums
,
minimums
,
avgs
=
data
.
max
(
axis
=
0
),
data
.
min
(
axis
=
0
),
data
.
sum
(
maximums
,
minimums
,
avgs
=
data
.
max
(
axis
=
0
),
data
.
min
(
axis
=
0
),
data
.
sum
(
axis
=
0
)
/
data
.
shape
[
0
]
axis
=
0
)
/
data
.
shape
[
0
]
feature_range
(
maximums
[:
-
1
],
minimums
[:
-
1
])
feature_range
(
maximums
[:
-
1
],
minimums
[:
-
1
])
for
i
in
range
(
feature_num
-
1
):
for
i
in
six
.
moves
.
range
(
feature_num
-
1
):
data
[:,
i
]
=
(
data
[:,
i
]
-
avgs
[
i
])
/
(
maximums
[
i
]
-
minimums
[
i
])
data
[:,
i
]
=
(
data
[:,
i
]
-
avgs
[
i
])
/
(
maximums
[
i
]
-
minimums
[
i
])
offset
=
int
(
data
.
shape
[
0
]
*
ratio
)
offset
=
int
(
data
.
shape
[
0
]
*
ratio
)
UCI_TRAIN_DATA
=
data
[:
offset
]
UCI_TRAIN_DATA
=
data
[:
offset
]
...
@@ -137,7 +138,7 @@ def predict_reader():
...
@@ -137,7 +138,7 @@ def predict_reader():
It returns just one tuple data to do inference.
It returns just one tuple data to do inference.
:return: one tuple data
:return: one tuple data
:rtype: tuple
:rtype: tuple
"""
"""
global
UCI_TEST_DATA
global
UCI_TEST_DATA
load_data
(
paddle
.
dataset
.
common
.
download
(
URL
,
'uci_housing'
,
MD5
))
load_data
(
paddle
.
dataset
.
common
.
download
(
URL
,
'uci_housing'
,
MD5
))
...
...
python/paddle/fluid/executor.py
浏览文件 @
1f618c4f
...
@@ -346,7 +346,7 @@ class Executor(object):
...
@@ -346,7 +346,7 @@ class Executor(object):
def
_fetch_data
(
self
,
fetch_list
,
fetch_var_name
,
scope
):
def
_fetch_data
(
self
,
fetch_list
,
fetch_var_name
,
scope
):
outs
=
[
outs
=
[
core
.
get_fetch_variable
(
scope
,
fetch_var_name
,
i
)
core
.
get_fetch_variable
(
scope
,
fetch_var_name
,
i
)
for
i
in
range
(
len
(
fetch_list
))
for
i
in
six
.
moves
.
range
(
len
(
fetch_list
))
]
]
return
outs
return
outs
...
...
python/paddle/fluid/framework.py
浏览文件 @
1f618c4f
...
@@ -1497,7 +1497,9 @@ class Program(object):
...
@@ -1497,7 +1497,9 @@ class Program(object):
else
:
else
:
p
=
Program
()
p
=
Program
()
p
.
desc
=
core
.
ProgramDesc
(
self
.
desc
)
p
.
desc
=
core
.
ProgramDesc
(
self
.
desc
)
p
.
blocks
=
[
Block
(
p
,
i
)
for
i
in
range
(
self
.
desc
.
num_blocks
())]
p
.
blocks
=
[
Block
(
p
,
i
)
for
i
in
six
.
moves
.
range
(
self
.
desc
.
num_blocks
())
]
p
.
_sync_with_cpp
()
p
.
_sync_with_cpp
()
p
.
_copy_param_info_from
(
self
)
p
.
_copy_param_info_from
(
self
)
...
@@ -1549,7 +1551,9 @@ class Program(object):
...
@@ -1549,7 +1551,9 @@ class Program(object):
targets_idx
.
append
([
t
.
block
.
idx
,
t
.
idx
])
targets_idx
.
append
([
t
.
block
.
idx
,
t
.
idx
])
res
=
Program
()
res
=
Program
()
res
.
desc
=
core
.
prune
(
self
.
desc
,
targets_idx
)
res
.
desc
=
core
.
prune
(
self
.
desc
,
targets_idx
)
res
.
blocks
=
[
Block
(
res
,
i
)
for
i
in
range
(
res
.
desc
.
num_blocks
())]
res
.
blocks
=
[
Block
(
res
,
i
)
for
i
in
six
.
moves
.
range
(
res
.
desc
.
num_blocks
())
]
res
.
_sync_with_cpp
()
res
.
_sync_with_cpp
()
return
res
return
res
...
@@ -1590,13 +1594,15 @@ class Program(object):
...
@@ -1590,13 +1594,15 @@ class Program(object):
root_block
.
_remove_var
(
var
.
name
())
root_block
.
_remove_var
(
var
.
name
())
# change all `is_test` attributes to True
# change all `is_test` attributes to True
for
i
in
range
(
res
.
desc
.
num_blocks
()):
for
i
in
six
.
moves
.
range
(
res
.
desc
.
num_blocks
()):
block
=
res
.
desc
.
block
(
i
)
block
=
res
.
desc
.
block
(
i
)
for
j
in
range
(
block
.
op_size
()):
for
j
in
six
.
moves
.
range
(
block
.
op_size
()):
op
=
block
.
op
(
j
)
op
=
block
.
op
(
j
)
if
op
.
has_attr
(
'is_test'
):
if
op
.
has_attr
(
'is_test'
):
op
.
set_attr
(
'is_test'
,
True
)
op
.
set_attr
(
'is_test'
,
True
)
res
.
blocks
=
[
Block
(
res
,
i
)
for
i
in
range
(
res
.
desc
.
num_blocks
())]
res
.
blocks
=
[
Block
(
res
,
i
)
for
i
in
six
.
moves
.
range
(
res
.
desc
.
num_blocks
())
]
res
.
_sync_with_cpp
()
res
.
_sync_with_cpp
()
return
res
return
res
...
@@ -1616,7 +1622,7 @@ class Program(object):
...
@@ -1616,7 +1622,7 @@ class Program(object):
"""
"""
p
=
Program
()
p
=
Program
()
p
.
desc
=
core
.
ProgramDesc
(
binary_str
)
p
.
desc
=
core
.
ProgramDesc
(
binary_str
)
p
.
blocks
=
[
Block
(
p
,
i
)
for
i
in
range
(
p
.
desc
.
num_blocks
())]
p
.
blocks
=
[
Block
(
p
,
i
)
for
i
in
six
.
moves
.
range
(
p
.
desc
.
num_blocks
())]
p
.
_sync_with_cpp
()
p
.
_sync_with_cpp
()
return
p
return
p
...
...
python/paddle/fluid/layer_helper.py
浏览文件 @
1f618c4f
...
@@ -85,7 +85,7 @@ class LayerHelper(object):
...
@@ -85,7 +85,7 @@ class LayerHelper(object):
raise
ValueError
(
"parameter number mismatch"
)
raise
ValueError
(
"parameter number mismatch"
)
elif
len
(
param_attr
)
==
1
and
length
!=
1
:
elif
len
(
param_attr
)
==
1
and
length
!=
1
:
tmp
=
[
None
]
*
length
tmp
=
[
None
]
*
length
for
i
in
range
(
length
):
for
i
in
six
.
moves
.
range
(
length
):
tmp
[
i
]
=
copy
.
deepcopy
(
param_attr
[
0
])
tmp
[
i
]
=
copy
.
deepcopy
(
param_attr
[
0
])
param_attr
=
tmp
param_attr
=
tmp
return
param_attr
return
param_attr
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
1f618c4f
...
@@ -21,6 +21,7 @@ from ..layer_helper import LayerHelper
...
@@ -21,6 +21,7 @@ from ..layer_helper import LayerHelper
from
.
import
tensor
from
.
import
tensor
from
.
import
nn
from
.
import
nn
import
math
import
math
import
six
from
functools
import
reduce
from
functools
import
reduce
__all__
=
[
__all__
=
[
...
@@ -102,7 +103,7 @@ def rpn_target_assign(loc,
...
@@ -102,7 +103,7 @@ def rpn_target_assign(loc,
examples.
examples.
Returns:
Returns:
tuple:
tuple:
A tuple(predicted_scores, predicted_location, target_label,
A tuple(predicted_scores, predicted_location, target_label,
target_bbox) is returned. The predicted_scores and
target_bbox) is returned. The predicted_scores and
predicted_location is the predicted result of the RPN.
predicted_location is the predicted result of the RPN.
...
@@ -113,7 +114,7 @@ def rpn_target_assign(loc,
...
@@ -113,7 +114,7 @@ def rpn_target_assign(loc,
anchors. The predicted_scores is a 2D Tensor with shape
anchors. The predicted_scores is a 2D Tensor with shape
[F + B, 1], and the shape of target_label is same as the shape
[F + B, 1], and the shape of target_label is same as the shape
of the predicted_scores, B is the number of the background
of the predicted_scores, B is the number of the background
anchors, the F and B is depends on the input of this operator.
anchors, the F and B is depends on the input of this operator.
Examples:
Examples:
.. code-block:: python
.. code-block:: python
...
@@ -230,8 +231,8 @@ def detection_output(loc,
...
@@ -230,8 +231,8 @@ def detection_output(loc,
nms_eta(float): The parameter for adaptive NMS.
nms_eta(float): The parameter for adaptive NMS.
Returns:
Returns:
Variable:
Variable:
The detection outputs is a LoDTensor with shape [No, 6].
The detection outputs is a LoDTensor with shape [No, 6].
Each row has six values: [label, confidence, xmin, ymin, xmax, ymax].
Each row has six values: [label, confidence, xmin, ymin, xmax, ymax].
`No` is the total number of detections in this mini-batch. For each
`No` is the total number of detections in this mini-batch. For each
...
@@ -501,7 +502,7 @@ def target_assign(input,
...
@@ -501,7 +502,7 @@ def target_assign(input,
Assumed that the row offset for each instance in `neg_indices` is called neg_lod,
Assumed that the row offset for each instance in `neg_indices` is called neg_lod,
for i-th instance and each `id` of neg_indices in this instance:
for i-th instance and each `id` of neg_indices in this instance:
.. code-block:: text
.. code-block:: text
out[i][id][0 : K] = {mismatch_value, mismatch_value, ...}
out[i][id][0 : K] = {mismatch_value, mismatch_value, ...}
...
@@ -519,11 +520,11 @@ def target_assign(input,
...
@@ -519,11 +520,11 @@ def target_assign(input,
mismatch_value (float32): Fill this value to the mismatched location.
mismatch_value (float32): Fill this value to the mismatched location.
Returns:
Returns:
tuple:
tuple:
A tuple(out, out_weight) is returned. out is a 3D Tensor with
A tuple(out, out_weight) is returned. out is a 3D Tensor with
shape [N, P, K], N and P is the same as they are in
shape [N, P, K], N and P is the same as they are in
`neg_indices`, K is the same as it in input of X. If
`neg_indices`, K is the same as it in input of X. If
`match_indices[i][j]`. out_weight is the weight for output with
`match_indices[i][j]`. out_weight is the weight for output with
the shape of [N, P, 1].
the shape of [N, P, 1].
Examples:
Examples:
...
@@ -822,7 +823,7 @@ def prior_box(input,
...
@@ -822,7 +823,7 @@ def prior_box(input,
offset(float): Prior boxes center offset. Default: 0.5
offset(float): Prior boxes center offset. Default: 0.5
name(str): Name of the prior box op. Default: None.
name(str): Name of the prior box op. Default: None.
min_max_aspect_ratios_order(bool): If set True, the output prior box is
min_max_aspect_ratios_order(bool): If set True, the output prior box is
in order of [min, max, aspect_ratios], which is consistent with
in order of [min, max, aspect_ratios], which is consistent with
Caffe. Please note, this order affects the weights order of
Caffe. Please note, this order affects the weights order of
convolution layer followed by and does not affect the final
convolution layer followed by and does not affect the final
detection results. Default: False.
detection results. Default: False.
...
@@ -965,7 +966,7 @@ def multi_box_head(inputs,
...
@@ -965,7 +966,7 @@ def multi_box_head(inputs,
stride(int|list|tuple): The stride of conv2d. Default:1,
stride(int|list|tuple): The stride of conv2d. Default:1,
name(str): Name of the prior box layer. Default: None.
name(str): Name of the prior box layer. Default: None.
min_max_aspect_ratios_order(bool): If set True, the output prior box is
min_max_aspect_ratios_order(bool): If set True, the output prior box is
in order of [min, max, aspect_ratios], which is consistent with
in order of [min, max, aspect_ratios], which is consistent with
Caffe. Please note, this order affects the weights order of
Caffe. Please note, this order affects the weights order of
convolution layer followed by and does not affect the fininal
convolution layer followed by and does not affect the fininal
detection results. Default: False.
detection results. Default: False.
...
@@ -1033,7 +1034,7 @@ def multi_box_head(inputs,
...
@@ -1033,7 +1034,7 @@ def multi_box_head(inputs,
min_sizes
=
[]
min_sizes
=
[]
max_sizes
=
[]
max_sizes
=
[]
step
=
int
(
math
.
floor
(((
max_ratio
-
min_ratio
))
/
(
num_layer
-
2
)))
step
=
int
(
math
.
floor
(((
max_ratio
-
min_ratio
))
/
(
num_layer
-
2
)))
for
ratio
in
range
(
min_ratio
,
max_ratio
+
1
,
step
):
for
ratio
in
six
.
moves
.
range
(
min_ratio
,
max_ratio
+
1
,
step
):
min_sizes
.
append
(
base_size
*
ratio
/
100.
)
min_sizes
.
append
(
base_size
*
ratio
/
100.
)
max_sizes
.
append
(
base_size
*
(
ratio
+
step
)
/
100.
)
max_sizes
.
append
(
base_size
*
(
ratio
+
step
)
/
100.
)
min_sizes
=
[
base_size
*
.
10
]
+
min_sizes
min_sizes
=
[
base_size
*
.
10
]
+
min_sizes
...
...
python/paddle/fluid/layers/io.py
浏览文件 @
1f618c4f
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
# limitations under the License.
# limitations under the License.
import
contextlib
import
contextlib
import
multiprocessing
import
multiprocessing
import
six
import
threading
import
threading
from
..data_feeder
import
DataFeeder
from
..data_feeder
import
DataFeeder
...
@@ -69,7 +70,7 @@ def data(name,
...
@@ -69,7 +70,7 @@ def data(name,
"""
"""
helper
=
LayerHelper
(
'data'
,
**
locals
())
helper
=
LayerHelper
(
'data'
,
**
locals
())
shape
=
list
(
shape
)
shape
=
list
(
shape
)
for
i
in
range
(
len
(
shape
)):
for
i
in
six
.
moves
.
range
(
len
(
shape
)):
if
shape
[
i
]
is
None
:
if
shape
[
i
]
is
None
:
shape
[
i
]
=
-
1
shape
[
i
]
=
-
1
append_batch_size
=
False
append_batch_size
=
False
...
@@ -674,7 +675,7 @@ def py_reader(capacity,
...
@@ -674,7 +675,7 @@ def py_reader(capacity,
def
__tensor_provider__
():
def
__tensor_provider__
():
for
slots
in
paddle_reader
():
for
slots
in
paddle_reader
():
yield
[
slots
[
str
(
idx
)]
for
idx
in
xrange
(
counter
)]
yield
[
slots
[
str
(
idx
)]
for
idx
in
six
.
moves
.
xrange
(
counter
)]
__set_tensor_provider__
(
__tensor_provider__
)
__set_tensor_provider__
(
__tensor_provider__
)
...
@@ -1005,7 +1006,7 @@ class Preprocessor(object):
...
@@ -1005,7 +1006,7 @@ class Preprocessor(object):
source_lod_levels
=
self
.
underlying_reader
.
desc
.
lod_levels
()
source_lod_levels
=
self
.
underlying_reader
.
desc
.
lod_levels
()
self
.
source_var_names
=
[
self
.
source_var_names
=
[
unique_name
(
"preprocessor_source"
)
unique_name
(
"preprocessor_source"
)
for
_
in
range
(
len
(
source_shapes
))
for
_
in
six
.
moves
.
range
(
len
(
source_shapes
))
]
]
source_vars
=
[]
source_vars
=
[]
for
var_name
,
shape
,
dtype
,
lod_level
in
zip
(
for
var_name
,
shape
,
dtype
,
lod_level
in
zip
(
...
...
python/paddle/fluid/nets.py
浏览文件 @
1f618c4f
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
six
from
.
import
layers
from
.
import
layers
__all__
=
[
__all__
=
[
...
@@ -210,7 +211,7 @@ def img_conv_group(input,
...
@@ -210,7 +211,7 @@ def img_conv_group(input,
conv_with_batchnorm
=
__extend_list__
(
conv_with_batchnorm
)
conv_with_batchnorm
=
__extend_list__
(
conv_with_batchnorm
)
conv_batchnorm_drop_rate
=
__extend_list__
(
conv_batchnorm_drop_rate
)
conv_batchnorm_drop_rate
=
__extend_list__
(
conv_batchnorm_drop_rate
)
for
i
in
range
(
len
(
conv_num_filter
)):
for
i
in
six
.
moves
.
range
(
len
(
conv_num_filter
)):
local_conv_act
=
conv_act
local_conv_act
=
conv_act
if
conv_with_batchnorm
[
i
]:
if
conv_with_batchnorm
[
i
]:
local_conv_act
=
None
local_conv_act
=
None
...
...
python/paddle/fluid/parallel_executor.py
浏览文件 @
1f618c4f
...
@@ -19,6 +19,7 @@ from . import framework
...
@@ -19,6 +19,7 @@ from . import framework
from
.
import
executor
from
.
import
executor
import
warnings
import
warnings
import
sys
import
sys
import
six
import
os
import
os
__all__
=
[
'ParallelExecutor'
,
'ExecutionStrategy'
,
'BuildStrategy'
]
__all__
=
[
'ParallelExecutor'
,
'ExecutionStrategy'
,
'BuildStrategy'
]
...
@@ -95,7 +96,7 @@ class ParallelExecutor(object):
...
@@ -95,7 +96,7 @@ class ParallelExecutor(object):
self
.
_places
=
[]
self
.
_places
=
[]
self
.
_act_places
=
[]
self
.
_act_places
=
[]
if
use_cuda
:
if
use_cuda
:
for
i
in
range
(
core
.
get_cuda_device_count
()):
for
i
in
six
.
moves
.
range
(
core
.
get_cuda_device_count
()):
p
=
core
.
Place
()
p
=
core
.
Place
()
self
.
_act_places
.
append
(
core
.
CUDAPlace
(
i
))
self
.
_act_places
.
append
(
core
.
CUDAPlace
(
i
))
p
.
set_place
(
self
.
_act_places
[
-
1
])
p
.
set_place
(
self
.
_act_places
[
-
1
])
...
@@ -103,7 +104,7 @@ class ParallelExecutor(object):
...
@@ -103,7 +104,7 @@ class ParallelExecutor(object):
else
:
else
:
cpu_num
=
int
(
cpu_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
for
i
in
range
(
cpu_num
):
for
i
in
six
.
moves
.
range
(
cpu_num
):
p
=
core
.
Place
()
p
=
core
.
Place
()
self
.
_act_places
.
append
(
core
.
CPUPlace
())
self
.
_act_places
.
append
(
core
.
CPUPlace
())
p
.
set_place
(
self
.
_act_places
[
-
1
])
p
.
set_place
(
self
.
_act_places
[
-
1
])
...
...
python/paddle/fluid/tests/demo/pyreader.py
浏览文件 @
1f618c4f
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
# limitations under the License.
# limitations under the License.
import
numpy
import
numpy
import
six
import
paddle
import
paddle
import
paddle.dataset.mnist
as
mnist
import
paddle.dataset.mnist
as
mnist
...
@@ -31,7 +32,7 @@ def network(is_train):
...
@@ -31,7 +32,7 @@ def network(is_train):
hidden
=
img
hidden
=
img
for
i
in
xrange
(
2
):
for
i
in
six
.
moves
.
xrange
(
2
):
hidden
=
fluid
.
layers
.
fc
(
input
=
hidden
,
size
=
100
,
act
=
'tanh'
)
hidden
=
fluid
.
layers
.
fc
(
input
=
hidden
,
size
=
100
,
act
=
'tanh'
)
hidden
=
fluid
.
layers
.
dropout
(
hidden
=
fluid
.
layers
.
dropout
(
hidden
,
dropout_prob
=
0.5
,
is_test
=
not
is_train
)
hidden
,
dropout_prob
=
0.5
,
is_test
=
not
is_train
)
...
@@ -74,7 +75,7 @@ def main():
...
@@ -74,7 +75,7 @@ def main():
test_reader
.
decorate_paddle_reader
(
paddle
.
batch
(
mnist
.
test
(),
512
))
test_reader
.
decorate_paddle_reader
(
paddle
.
batch
(
mnist
.
test
(),
512
))
for
epoch_id
in
xrange
(
10
):
for
epoch_id
in
six
.
moves
.
xrange
(
10
):
train_reader
.
start
()
train_reader
.
start
()
try
:
try
:
while
True
:
while
True
:
...
...
python/paddle/fluid/tests/unittests/dist_transformer.py
浏览文件 @
1f618c4f
...
@@ -22,6 +22,7 @@ import paddle.fluid as fluid
...
@@ -22,6 +22,7 @@ import paddle.fluid as fluid
from
paddle.fluid
import
core
from
paddle.fluid
import
core
import
os
import
os
import
sys
import
sys
import
six
import
transformer_model
import
transformer_model
import
paddle.dataset.wmt16
as
wmt16
import
paddle.dataset.wmt16
as
wmt16
...
@@ -222,7 +223,7 @@ class DistTransformer2x2(object):
...
@@ -222,7 +223,7 @@ class DistTransformer2x2(object):
first_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
first_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
print
(
first_loss
)
print
(
first_loss
)
for
i
in
xrange
(
5
):
for
i
in
six
.
moves
.
xrange
(
5
):
_
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
_
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
last_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
last_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
print
(
last_loss
)
print
(
last_loss
)
...
...
python/paddle/fluid/tests/unittests/test_split_ids_op.py
浏览文件 @
1f618c4f
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
import
six
from
op_test
import
OpTest
from
op_test
import
OpTest
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
from
paddle.fluid.op
import
Operator
...
@@ -59,7 +60,7 @@ class TestSpliteIds(unittest.TestCase):
...
@@ -59,7 +60,7 @@ class TestSpliteIds(unittest.TestCase):
x_tensor
=
x
.
get_tensor
()
x_tensor
=
x
.
get_tensor
()
x_tensor
.
set
(
np_array
,
place
)
x_tensor
.
set
(
np_array
,
place
)
outs_name
=
[
"out%d"
%
i
for
i
in
xrange
(
3
)]
outs_name
=
[
"out%d"
%
i
for
i
in
six
.
moves
.
xrange
(
3
)]
outs
=
[
outs
=
[
scope
.
var
(
var_name
).
get_selected_rows
()
for
var_name
in
outs_name
scope
.
var
(
var_name
).
get_selected_rows
()
for
var_name
in
outs_name
]
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录