Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d23bae7b
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看板
提交
d23bae7b
编写于
1月 11, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of github.com:baidu/Paddle into feature/c_api
上级
fe8d5ff3
9e6c8cdb
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
46 addition
and
11 deletion
+46
-11
cmake/external/python.cmake
cmake/external/python.cmake
+4
-0
cmake/python_module.cmake
cmake/python_module.cmake
+13
-0
doc/howto/usage/k8s/k8s_distributed_cn.md
doc/howto/usage/k8s/k8s_distributed_cn.md
+4
-0
paddle/math/Matrix.cpp
paddle/math/Matrix.cpp
+18
-6
paddle/math/tests/test_Matrix.cpp
paddle/math/tests/test_Matrix.cpp
+3
-2
paddle/math/tests/test_matrixCompare.cpp
paddle/math/tests/test_matrixCompare.cpp
+3
-2
paddle/setup.py.in
paddle/setup.py.in
+1
-1
未找到文件。
cmake/external/python.cmake
浏览文件 @
d23bae7b
...
@@ -26,6 +26,10 @@ IF(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
...
@@ -26,6 +26,10 @@ IF(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
find_python_module
(
wheel REQUIRED
)
find_python_module
(
wheel REQUIRED
)
find_python_module
(
google.protobuf REQUIRED
)
find_python_module
(
google.protobuf REQUIRED
)
FIND_PACKAGE
(
NumPy REQUIRED
)
FIND_PACKAGE
(
NumPy REQUIRED
)
IF
(
${
PY_GOOGLE.PROTOBUF_VERSION
}
VERSION_LESS
"3.0.0"
)
MESSAGE
(
FATAL_ERROR
"Found Python Protobuf
${
PY_GOOGLE.PROTOBUF_VERSION
}
< 3.0.0, "
"please use pip to upgrade protobuf."
)
ENDIF
(
${
PY_GOOGLE.PROTOBUF_VERSION
}
VERSION_LESS
"3.0.0"
)
ELSE
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
ELSE
(
PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
)
##################################### PYTHON ########################################
##################################### PYTHON ########################################
SET
(
PYTHON_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/python
)
SET
(
PYTHON_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/python
)
...
...
cmake/python_module.cmake
浏览文件 @
d23bae7b
...
@@ -26,5 +26,18 @@ function(find_python_module module)
...
@@ -26,5 +26,18 @@ function(find_python_module module)
if
(
NOT PY_
${
module_upper
}
_FOUND AND
${
module
}
_FIND_REQUIRED
)
if
(
NOT PY_
${
module_upper
}
_FOUND AND
${
module
}
_FIND_REQUIRED
)
message
(
FATAL_ERROR
"python module
${
module
}
is not found"
)
message
(
FATAL_ERROR
"python module
${
module
}
is not found"
)
endif
()
endif
()
execute_process
(
COMMAND
"
${
PYTHON_EXECUTABLE
}
"
"-c"
"import sys,
${
module
}
; sys.stdout.write(
${
module
}
.__version__)"
OUTPUT_VARIABLE _
${
module
}
_version
RESULT_VARIABLE _
${
module
}
_status
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
NOT _
${
module
}
_status
)
set
(
PY_
${
module_upper
}
_VERSION
${
_
${
module
}
_version
}
CACHE STRING
"Version of Python module
${
module
}
"
)
endif
(
NOT _
${
module
}
_status
)
set
(
PY_
${
module_upper
}
_FOUND
${
PY_
${
module_upper
}
_FOUND
}
PARENT_SCOPE
)
set
(
PY_
${
module_upper
}
_FOUND
${
PY_
${
module_upper
}
_FOUND
}
PARENT_SCOPE
)
set
(
PY_
${
module_upper
}
_VERSION
${
PY_
${
module_upper
}
_VERSION
}
PARENT_SCOPE
)
endfunction
(
find_python_module
)
endfunction
(
find_python_module
)
doc/howto/usage/k8s/k8s_distributed_cn.md
浏览文件 @
d23bae7b
...
@@ -159,6 +159,8 @@ docker build -t your_repo/paddle:mypaddle .
...
@@ -159,6 +159,8 @@ docker build -t your_repo/paddle:mypaddle .
docker push your_repo/paddle:mypaddle
docker push your_repo/paddle:mypaddle
```
```
注意上述命令中
`your_repo`
表示读者所使用的Docker镜像仓库地址,读者需要替换成自己使用的仓库地址。下文使用
`your_repo/paddle:mypaddle`
这个地址来表示此步骤所构建出的镜像。
### 上传训练文件
### 上传训练文件
本文使用PaddlePaddle官方的
[
recommendation demo
](
http://www.paddlepaddle.org/doc/demo/index.html#recommendation
)
作为这次训练的内容,我们将训练文件与数据放在一个job name命名的目录中,上传到MFS共享存储。完成后MFS上的文件内容大致如下:
本文使用PaddlePaddle官方的
[
recommendation demo
](
http://www.paddlepaddle.org/doc/demo/index.html#recommendation
)
作为这次训练的内容,我们将训练文件与数据放在一个job name命名的目录中,上传到MFS共享存储。完成后MFS上的文件内容大致如下:
...
@@ -244,6 +246,8 @@ spec:
...
@@ -244,6 +246,8 @@ spec:
`CONF_PADDLE_GRADIENT_NUM`
表示训练节点数量,即
`--num_gradient_servers`
参数
`CONF_PADDLE_GRADIENT_NUM`
表示训练节点数量,即
`--num_gradient_servers`
参数
这些参数的具体描述,读者可以查看
[
这里
](
http://www.paddlepaddle.org/doc/ui/cmd_argument/detail_introduction.html#parameter-server-and-distributed-communication
)
。
编写完YAML文件后,可以使用Kubernetes的命令行工具创建job。
编写完YAML文件后,可以使用Kubernetes的命令行工具创建job。
```
bash
```
bash
...
...
paddle/math/Matrix.cpp
浏览文件 @
d23bae7b
...
@@ -1311,7 +1311,9 @@ void GpuMatrix::paramReluForward(Matrix& data, Matrix& W) {
...
@@ -1311,7 +1311,9 @@ void GpuMatrix::paramReluForward(Matrix& data, Matrix& W) {
real
*
w
=
W
.
getData
();
real
*
w
=
W
.
getData
();
size_t
numElements
=
data
.
getWidth
();
size_t
numElements
=
data
.
getWidth
();
size_t
numSamples
=
data
.
getHeight
();
size_t
numSamples
=
data
.
getHeight
();
size_t
partial_sum
=
numElements
/
(
W
.
getHeight
()
*
W
.
getWidth
());
size_t
paraSize
=
W
.
getHeight
()
*
W
.
getWidth
();
CHECK
(
!
(
numElements
%
paraSize
));
// this check from ParameterReluLayer::init
size_t
partial_sum
=
numElements
/
paraSize
;
real
*
output
=
getData
();
real
*
output
=
getData
();
hl_param_relu_forward
(
output
,
input
,
w
,
numElements
,
numSamples
,
partial_sum
);
hl_param_relu_forward
(
output
,
input
,
w
,
numElements
,
numSamples
,
partial_sum
);
}
}
...
@@ -1324,7 +1326,9 @@ void GpuMatrix::paramReluBackwardW(Matrix& oGrad, Matrix& data) {
...
@@ -1324,7 +1326,9 @@ void GpuMatrix::paramReluBackwardW(Matrix& oGrad, Matrix& data) {
real
*
wgrad
=
data_
;
real
*
wgrad
=
data_
;
size_t
numElements
=
data
.
getWidth
();
size_t
numElements
=
data
.
getWidth
();
size_t
numSamples
=
data
.
getHeight
();
size_t
numSamples
=
data
.
getHeight
();
size_t
partial_sum
=
numElements
/
(
this
->
getHeight
()
*
this
->
getWidth
());
size_t
paraSize
=
this
->
getHeight
()
*
this
->
getWidth
();
CHECK
(
!
(
numElements
%
paraSize
));
// this check from ParameterReluLayer::init
size_t
partial_sum
=
numElements
/
paraSize
;
hl_param_relu_backward_w
(
hl_param_relu_backward_w
(
wgrad
,
ograd
,
input
,
numElements
,
numSamples
,
partial_sum
);
wgrad
,
ograd
,
input
,
numElements
,
numSamples
,
partial_sum
);
}
}
...
@@ -1336,7 +1340,9 @@ void GpuMatrix::paramReluBackwardDiff(Matrix& oGrad, Matrix& data, Matrix& W) {
...
@@ -1336,7 +1340,9 @@ void GpuMatrix::paramReluBackwardDiff(Matrix& oGrad, Matrix& data, Matrix& W) {
real
*
w
=
W
.
getData
();
real
*
w
=
W
.
getData
();
size_t
numElements
=
data
.
getWidth
();
size_t
numElements
=
data
.
getWidth
();
size_t
numSamples
=
data
.
getHeight
();
size_t
numSamples
=
data
.
getHeight
();
size_t
partial_sum
=
numElements
/
(
W
.
getHeight
()
*
W
.
getWidth
());
size_t
paraSize
=
W
.
getHeight
()
*
W
.
getWidth
();
CHECK
(
!
(
numElements
%
paraSize
));
// this check from ParameterReluLayer::init
size_t
partial_sum
=
numElements
/
paraSize
;
hl_param_relu_backward_diff
(
hl_param_relu_backward_diff
(
ograd
,
input
,
w
,
diff
,
numElements
,
numSamples
,
partial_sum
);
ograd
,
input
,
w
,
diff
,
numElements
,
numSamples
,
partial_sum
);
}
}
...
@@ -3764,7 +3770,9 @@ void CpuMatrix::paramReluForward(Matrix& data, Matrix& W) {
...
@@ -3764,7 +3770,9 @@ void CpuMatrix::paramReluForward(Matrix& data, Matrix& W) {
real
*
w
=
W
.
getData
();
real
*
w
=
W
.
getData
();
size_t
numElements
=
data
.
getWidth
();
size_t
numElements
=
data
.
getWidth
();
size_t
numSamples
=
data
.
getHeight
();
size_t
numSamples
=
data
.
getHeight
();
size_t
partial_sum
=
numElements
/
(
W
.
getHeight
()
*
W
.
getWidth
());
size_t
paraSize
=
W
.
getHeight
()
*
W
.
getWidth
();
CHECK
(
!
(
numElements
%
paraSize
));
// this check from ParameterReluLayer::init
size_t
partial_sum
=
numElements
/
paraSize
;
for
(
size_t
n
=
0
,
k
=
0
;
n
<
numSamples
;
++
n
)
{
for
(
size_t
n
=
0
,
k
=
0
;
n
<
numSamples
;
++
n
)
{
for
(
size_t
i
=
0
;
i
<
numElements
;
++
i
,
++
k
)
{
for
(
size_t
i
=
0
;
i
<
numElements
;
++
i
,
++
k
)
{
data_
[
k
]
=
input
[
k
]
>
0
?
input
[
k
]
:
input
[
k
]
*
w
[
i
/
partial_sum
];
data_
[
k
]
=
input
[
k
]
>
0
?
input
[
k
]
:
input
[
k
]
*
w
[
i
/
partial_sum
];
...
@@ -3778,7 +3786,9 @@ void CpuMatrix::paramReluBackwardW(Matrix& oGrad, Matrix& data) {
...
@@ -3778,7 +3786,9 @@ void CpuMatrix::paramReluBackwardW(Matrix& oGrad, Matrix& data) {
real
*
wgrad
=
data_
;
real
*
wgrad
=
data_
;
size_t
numElements
=
data
.
getWidth
();
size_t
numElements
=
data
.
getWidth
();
size_t
numSamples
=
data
.
getHeight
();
size_t
numSamples
=
data
.
getHeight
();
size_t
partial_sum
=
numElements
/
(
this
->
getHeight
()
*
this
->
getWidth
());
size_t
paraSize
=
this
->
getHeight
()
*
this
->
getWidth
();
CHECK
(
!
(
numElements
%
paraSize
));
// this check from ParameterReluLayer::init
size_t
partial_sum
=
numElements
/
paraSize
;
for
(
size_t
n
=
0
,
k
=
0
;
n
<
numSamples
;
++
n
)
{
for
(
size_t
n
=
0
,
k
=
0
;
n
<
numSamples
;
++
n
)
{
for
(
size_t
i
=
0
;
i
<
numElements
;
++
i
,
++
k
)
{
for
(
size_t
i
=
0
;
i
<
numElements
;
++
i
,
++
k
)
{
wgrad
[
i
/
partial_sum
]
+=
ograd
[
k
]
*
(
input
[
k
]
>
0
?
0
:
input
[
k
]);
wgrad
[
i
/
partial_sum
]
+=
ograd
[
k
]
*
(
input
[
k
]
>
0
?
0
:
input
[
k
]);
...
@@ -3793,7 +3803,9 @@ void CpuMatrix::paramReluBackwardDiff(Matrix& oGrad, Matrix& data, Matrix& W) {
...
@@ -3793,7 +3803,9 @@ void CpuMatrix::paramReluBackwardDiff(Matrix& oGrad, Matrix& data, Matrix& W) {
real
*
w
=
W
.
getData
();
real
*
w
=
W
.
getData
();
size_t
numElements
=
data
.
getWidth
();
size_t
numElements
=
data
.
getWidth
();
size_t
numSamples
=
data
.
getHeight
();
size_t
numSamples
=
data
.
getHeight
();
size_t
partial_sum
=
numElements
/
(
W
.
getHeight
()
*
W
.
getWidth
());
size_t
paraSize
=
W
.
getHeight
()
*
W
.
getWidth
();
CHECK
(
!
(
numElements
%
paraSize
));
// this check from ParameterReluLayer::init
size_t
partial_sum
=
numElements
/
paraSize
;
for
(
size_t
n
=
0
,
k
=
0
;
n
<
numSamples
;
++
n
)
{
for
(
size_t
n
=
0
,
k
=
0
;
n
<
numSamples
;
++
n
)
{
for
(
size_t
i
=
0
;
i
<
numElements
;
++
i
,
++
k
)
{
for
(
size_t
i
=
0
;
i
<
numElements
;
++
i
,
++
k
)
{
diff
[
k
]
+=
ograd
[
k
]
*
(
input
[
k
]
>
0
?
1
:
w
[
i
/
partial_sum
]);
diff
[
k
]
+=
ograd
[
k
]
*
(
input
[
k
]
>
0
?
1
:
w
[
i
/
partial_sum
]);
...
...
paddle/math/tests/test_Matrix.cpp
浏览文件 @
d23bae7b
...
@@ -224,10 +224,11 @@ void testParamReluBackwardW(int height, int width, int w_height, int w_width) {
...
@@ -224,10 +224,11 @@ void testParamReluBackwardW(int height, int width, int w_height, int w_width) {
}
}
TEST
(
Matrix
,
paramRelu
)
{
TEST
(
Matrix
,
paramRelu
)
{
for
(
auto
height
:
{
10
,
100
})
{
for
(
auto
height
:
{
10
,
40
,
100
})
{
for
(
auto
width
:
{
10
,
100
})
{
for
(
auto
width
:
{
10
,
40
,
100
})
{
for
(
auto
w_height
:
{
1
,
2
})
{
for
(
auto
w_height
:
{
1
,
2
})
{
for
(
auto
w_width
:
{
1
,
2
})
{
for
(
auto
w_width
:
{
1
,
2
})
{
if
(
width
%
(
w_height
*
w_width
))
continue
;
testParamReluForward
(
height
,
width
,
w_height
,
w_width
);
testParamReluForward
(
height
,
width
,
w_height
,
w_width
);
testParamReluBackwardW
(
height
,
width
,
w_height
,
w_width
);
testParamReluBackwardW
(
height
,
width
,
w_height
,
w_width
);
}
}
...
...
paddle/math/tests/test_matrixCompare.cpp
浏览文件 @
d23bae7b
...
@@ -773,10 +773,11 @@ void testParamReluBackwardDiff(int height,
...
@@ -773,10 +773,11 @@ void testParamReluBackwardDiff(int height,
}
}
TEST
(
Matrix
,
paramReluBackwardDiff
)
{
TEST
(
Matrix
,
paramReluBackwardDiff
)
{
for
(
auto
height
:
{
10
,
100
})
{
for
(
auto
height
:
{
10
,
40
,
100
})
{
for
(
auto
width
:
{
10
,
100
})
{
for
(
auto
width
:
{
10
,
40
,
100
})
{
for
(
auto
w_height
:
{
1
,
2
})
{
for
(
auto
w_height
:
{
1
,
2
})
{
for
(
auto
w_width
:
{
1
,
2
})
{
for
(
auto
w_width
:
{
1
,
2
})
{
if
(
width
%
(
w_height
*
w_width
))
continue
;
testParamReluBackwardDiff
(
height
,
width
,
w_height
,
w_width
);
testParamReluBackwardDiff
(
height
,
width
,
w_height
,
w_width
);
}
}
}
}
...
...
paddle/setup.py.in
浏览文件 @
d23bae7b
...
@@ -70,6 +70,6 @@ setup(name="py_paddle",
...
@@ -70,6 +70,6 @@ setup(name="py_paddle",
include_dirs = include_dirs,
include_dirs = include_dirs,
install_requires = [
install_requires = [
'numpy>=1.8.0', # The numpy is required.
'numpy>=1.8.0', # The numpy is required.
'protobuf>=
2.4.1'
# The paddle protobuf version
'protobuf>=
3.0.0'
# The paddle protobuf version
],
],
)
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录