Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
1f618c4f
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
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
import
gzip
import
itertools
import
paddle.dataset.common
from
six.moves
import
zip
from
six.moves
import
zip
,
range
__all__
=
[
'test, get_dict'
,
'get_embedding'
,
'convert'
]
...
...
python/paddle/dataset/imdb.py
浏览文件 @
1f618c4f
...
...
@@ -25,6 +25,7 @@ import collections
import
tarfile
import
re
import
string
from
six.moves
import
range
__all__
=
[
'build_dict'
,
'train'
,
'test'
,
'convert'
]
...
...
@@ -66,7 +67,7 @@ def build_dict(pattern, cutoff):
dictionary
=
sorted
(
word_freq
,
key
=
lambda
x
:
(
-
x
[
1
],
x
[
0
]))
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
)
return
word_idx
...
...
python/paddle/dataset/imikolov.py
浏览文件 @
1f618c4f
...
...
@@ -14,13 +14,14 @@
"""
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
into paddle reader creators.
"""
import
paddle.dataset.common
import
collections
import
tarfile
from
six.moves
import
range
__all__
=
[
'train'
,
'test'
,
'build_dict'
,
'convert'
]
...
...
@@ -68,7 +69,7 @@ def build_dict(min_word_freq=50):
word_freq_sorted
=
sorted
(
word_freq
,
key
=
lambda
x
:
(
-
x
[
1
],
x
[
0
]))
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
)
return
word_idx
...
...
python/paddle/dataset/mnist.py
浏览文件 @
1f618c4f
...
...
@@ -21,6 +21,7 @@ import paddle.dataset.common
import
subprocess
import
numpy
import
platform
from
six.moves
import
range
__all__
=
[
'train'
,
'test'
,
'convert'
]
URL_PREFIX
=
'http://yann.lecun.com/exdb/mnist/'
...
...
python/paddle/dataset/tests/common_test.py
浏览文件 @
1f618c4f
...
...
@@ -16,6 +16,7 @@ import paddle.dataset.common
import
unittest
import
tempfile
import
glob
from
six.moves
import
range
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.
import
os
import
numpy
as
np
import
six
import
tempfile
import
tarfile
import
os
...
...
@@ -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
(
axis
=
0
)
/
data
.
shape
[
0
]
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
])
offset
=
int
(
data
.
shape
[
0
]
*
ratio
)
UCI_TRAIN_DATA
=
data
[:
offset
]
...
...
@@ -137,7 +138,7 @@ def predict_reader():
It returns just one tuple data to do inference.
:return: one tuple data
:rtype: tuple
:rtype: tuple
"""
global
UCI_TEST_DATA
load_data
(
paddle
.
dataset
.
common
.
download
(
URL
,
'uci_housing'
,
MD5
))
...
...
python/paddle/fluid/executor.py
浏览文件 @
1f618c4f
...
...
@@ -346,7 +346,7 @@ class Executor(object):
def
_fetch_data
(
self
,
fetch_list
,
fetch_var_name
,
scope
):
outs
=
[
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
...
...
python/paddle/fluid/framework.py
浏览文件 @
1f618c4f
...
...
@@ -1497,7 +1497,9 @@ class Program(object):
else
:
p
=
Program
()
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
.
_copy_param_info_from
(
self
)
...
...
@@ -1549,7 +1551,9 @@ class Program(object):
targets_idx
.
append
([
t
.
block
.
idx
,
t
.
idx
])
res
=
Program
()
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
()
return
res
...
...
@@ -1590,13 +1594,15 @@ class Program(object):
root_block
.
_remove_var
(
var
.
name
())
# 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
)
for
j
in
range
(
block
.
op_size
()):
for
j
in
six
.
moves
.
range
(
block
.
op_size
()):
op
=
block
.
op
(
j
)
if
op
.
has_attr
(
'is_test'
):
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
()
return
res
...
...
@@ -1616,7 +1622,7 @@ class Program(object):
"""
p
=
Program
()
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
()
return
p
...
...
python/paddle/fluid/layer_helper.py
浏览文件 @
1f618c4f
...
...
@@ -85,7 +85,7 @@ class LayerHelper(object):
raise
ValueError
(
"parameter number mismatch"
)
elif
len
(
param_attr
)
==
1
and
length
!=
1
:
tmp
=
[
None
]
*
length
for
i
in
range
(
length
):
for
i
in
six
.
moves
.
range
(
length
):
tmp
[
i
]
=
copy
.
deepcopy
(
param_attr
[
0
])
param_attr
=
tmp
return
param_attr
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
1f618c4f
...
...
@@ -21,6 +21,7 @@ from ..layer_helper import LayerHelper
from
.
import
tensor
from
.
import
nn
import
math
import
six
from
functools
import
reduce
__all__
=
[
...
...
@@ -102,7 +103,7 @@ def rpn_target_assign(loc,
examples.
Returns:
tuple:
tuple:
A tuple(predicted_scores, predicted_location, target_label,
target_bbox) is returned. The predicted_scores and
predicted_location is the predicted result of the RPN.
...
...
@@ -113,7 +114,7 @@ def rpn_target_assign(loc,
anchors. The predicted_scores is a 2D Tensor with 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
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:
.. code-block:: python
...
...
@@ -230,8 +231,8 @@ def detection_output(loc,
nms_eta(float): The parameter for adaptive NMS.
Returns:
Variable:
Variable:
The detection outputs is a LoDTensor with shape [No, 6].
Each row has six values: [label, confidence, xmin, ymin, xmax, ymax].
`No` is the total number of detections in this mini-batch. For each
...
...
@@ -501,7 +502,7 @@ def target_assign(input,
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:
.. code-block:: text
out[i][id][0 : K] = {mismatch_value, mismatch_value, ...}
...
...
@@ -519,11 +520,11 @@ def target_assign(input,
mismatch_value (float32): Fill this value to the mismatched location.
Returns:
tuple:
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
`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
tuple:
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
`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
the shape of [N, P, 1].
Examples:
...
...
@@ -822,7 +823,7 @@ def prior_box(input,
offset(float): Prior boxes center offset. Default: 0.5
name(str): Name of the prior box op. Default: None.
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
convolution layer followed by and does not affect the final
detection results. Default: False.
...
...
@@ -965,7 +966,7 @@ def multi_box_head(inputs,
stride(int|list|tuple): The stride of conv2d. Default:1,
name(str): Name of the prior box layer. Default: None.
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
convolution layer followed by and does not affect the fininal
detection results. Default: False.
...
...
@@ -1033,7 +1034,7 @@ def multi_box_head(inputs,
min_sizes
=
[]
max_sizes
=
[]
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.
)
max_sizes
.
append
(
base_size
*
(
ratio
+
step
)
/
100.
)
min_sizes
=
[
base_size
*
.
10
]
+
min_sizes
...
...
python/paddle/fluid/layers/io.py
浏览文件 @
1f618c4f
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
import
contextlib
import
multiprocessing
import
six
import
threading
from
..data_feeder
import
DataFeeder
...
...
@@ -69,7 +70,7 @@ def data(name,
"""
helper
=
LayerHelper
(
'data'
,
**
locals
())
shape
=
list
(
shape
)
for
i
in
range
(
len
(
shape
)):
for
i
in
six
.
moves
.
range
(
len
(
shape
)):
if
shape
[
i
]
is
None
:
shape
[
i
]
=
-
1
append_batch_size
=
False
...
...
@@ -674,7 +675,7 @@ def py_reader(capacity,
def
__tensor_provider__
():
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__
)
...
...
@@ -1005,7 +1006,7 @@ class Preprocessor(object):
source_lod_levels
=
self
.
underlying_reader
.
desc
.
lod_levels
()
self
.
source_var_names
=
[
unique_name
(
"preprocessor_source"
)
for
_
in
range
(
len
(
source_shapes
))
for
_
in
six
.
moves
.
range
(
len
(
source_shapes
))
]
source_vars
=
[]
for
var_name
,
shape
,
dtype
,
lod_level
in
zip
(
...
...
python/paddle/fluid/nets.py
浏览文件 @
1f618c4f
...
...
@@ -11,6 +11,7 @@
# 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.
import
six
from
.
import
layers
__all__
=
[
...
...
@@ -210,7 +211,7 @@ def img_conv_group(input,
conv_with_batchnorm
=
__extend_list__
(
conv_with_batchnorm
)
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
if
conv_with_batchnorm
[
i
]:
local_conv_act
=
None
...
...
python/paddle/fluid/parallel_executor.py
浏览文件 @
1f618c4f
...
...
@@ -19,6 +19,7 @@ from . import framework
from
.
import
executor
import
warnings
import
sys
import
six
import
os
__all__
=
[
'ParallelExecutor'
,
'ExecutionStrategy'
,
'BuildStrategy'
]
...
...
@@ -95,7 +96,7 @@ class ParallelExecutor(object):
self
.
_places
=
[]
self
.
_act_places
=
[]
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
()
self
.
_act_places
.
append
(
core
.
CUDAPlace
(
i
))
p
.
set_place
(
self
.
_act_places
[
-
1
])
...
...
@@ -103,7 +104,7 @@ class ParallelExecutor(object):
else
:
cpu_num
=
int
(
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
()
self
.
_act_places
.
append
(
core
.
CPUPlace
())
p
.
set_place
(
self
.
_act_places
[
-
1
])
...
...
python/paddle/fluid/tests/demo/pyreader.py
浏览文件 @
1f618c4f
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
import
numpy
import
six
import
paddle
import
paddle.dataset.mnist
as
mnist
...
...
@@ -31,7 +32,7 @@ def network(is_train):
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
.
dropout
(
hidden
,
dropout_prob
=
0.5
,
is_test
=
not
is_train
)
...
...
@@ -74,7 +75,7 @@ def main():
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
()
try
:
while
True
:
...
...
python/paddle/fluid/tests/unittests/dist_transformer.py
浏览文件 @
1f618c4f
...
...
@@ -22,6 +22,7 @@ import paddle.fluid as fluid
from
paddle.fluid
import
core
import
os
import
sys
import
six
import
transformer_model
import
paddle.dataset.wmt16
as
wmt16
...
...
@@ -222,7 +223,7 @@ class DistTransformer2x2(object):
first_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
print
(
first_loss
)
for
i
in
xrange
(
5
):
for
i
in
six
.
moves
.
xrange
(
5
):
_
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
last_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
print
(
last_loss
)
...
...
python/paddle/fluid/tests/unittests/test_split_ids_op.py
浏览文件 @
1f618c4f
...
...
@@ -14,6 +14,7 @@
import
unittest
import
numpy
as
np
import
six
from
op_test
import
OpTest
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
...
...
@@ -59,7 +60,7 @@ class TestSpliteIds(unittest.TestCase):
x_tensor
=
x
.
get_tensor
()
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
=
[
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录