Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
cd5fad13
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
cd5fad13
编写于
1月 04, 2018
作者:
Y
Yu Yang
提交者:
GitHub
1月 04, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7160 from reyoung/feature/expose_activations
Expose some activations
上级
a893f156
5a4367bb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
44 addition
and
12 deletion
+44
-12
paddle/framework/init.cc
paddle/framework/init.cc
+5
-0
paddle/framework/init.h
paddle/framework/init.h
+2
-0
paddle/framework/lod_tensor.cc
paddle/framework/lod_tensor.cc
+3
-0
paddle/operators/activation_op.h
paddle/operators/activation_op.h
+11
-6
paddle/pybind/pybind.cc
paddle/pybind/pybind.cc
+1
-0
python/paddle/v2/fluid/__init__.py
python/paddle/v2/fluid/__init__.py
+3
-2
python/paddle/v2/fluid/layers/ops.py
python/paddle/v2/fluid/layers/ops.py
+19
-4
未找到文件。
paddle/framework/init.cc
浏览文件 @
cd5fad13
...
...
@@ -75,5 +75,10 @@ bool InitDevices(const std::vector<std::string> &devices) {
return
true
;
}
void
InitGLOG
(
const
std
::
string
&
prog_name
)
{
google
::
InitGoogleLogging
(
prog_name
.
c_str
());
google
::
InstallFailureSignalHandler
();
}
}
// namespace framework
}
// namespace paddle
paddle/framework/init.h
浏览文件 @
cd5fad13
...
...
@@ -22,6 +22,8 @@ namespace framework {
void
InitGflags
(
std
::
vector
<
std
::
string
>
&
argv
);
void
InitGLOG
(
const
std
::
string
&
prog_name
);
bool
InitDevices
(
const
std
::
vector
<
std
::
string
>
&
devices
);
}
// namespace framework
...
...
paddle/framework/lod_tensor.cc
浏览文件 @
cd5fad13
...
...
@@ -177,6 +177,9 @@ void AppendLoD(LoD *lod, const LoD &lod_length) {
lod
->
empty
()
||
lod
->
size
()
==
lod_length
.
size
(),
"The lod_length should has the same size with the appended lod."
);
if
(
lod
->
empty
())
{
for
(
size_t
i
=
0
;
i
<
lod_length
.
size
();
++
i
)
{
lod
->
emplace_back
(
1
,
0
);
// size = 1, value = 0;
}
*
lod
=
LoD
(
lod_length
.
size
(),
std
::
vector
<
size_t
>
({
0
}));
}
for
(
size_t
i
=
0
;
i
<
lod
->
size
();
++
i
)
{
...
...
paddle/operators/activation_op.h
浏览文件 @
cd5fad13
...
...
@@ -15,6 +15,7 @@ limitations under the License. */
#pragma once
#include "paddle/framework/eigen.h"
#include "paddle/framework/op_registry.h"
#include "paddle/operators/detail/safe_ref.h"
namespace
paddle
{
namespace
operators
{
...
...
@@ -26,12 +27,16 @@ class ActivationKernel
using
T
=
typename
Functor
::
ELEMENT_TYPE
;
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
auto
*
X
=
context
.
Input
<
framework
::
Tensor
>
(
"X"
);
auto
*
Out
=
context
.
Output
<
framework
::
Tensor
>
(
"Out"
);
Out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
x
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
X
);
auto
out
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
Out
);
auto
&
X
=
detail
::
Ref
(
context
.
Input
<
framework
::
Tensor
>
(
"X"
),
"Cannot get input tensor X, variable name = %s"
,
context
.
op
().
Input
(
"X"
));
auto
&
Out
=
detail
::
Ref
(
context
.
Output
<
framework
::
Tensor
>
(
"Out"
),
"Cannot get output tensor Out, variable name = %s"
,
context
.
op
().
Output
(
"Out"
));
Out
.
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
x
=
framework
::
EigenVector
<
T
>::
Flatten
(
X
);
auto
out
=
framework
::
EigenVector
<
T
>::
Flatten
(
Out
);
auto
*
place
=
context
.
template
device_context
<
DeviceContext
>().
eigen_device
();
Functor
functor
;
...
...
paddle/pybind/pybind.cc
浏览文件 @
cd5fad13
...
...
@@ -427,6 +427,7 @@ All parameter, weight, gradient are variables in Paddle.
m
.
def
(
"unique_integer"
,
UniqueIntegerGenerator
);
m
.
def
(
"init_gflags"
,
framework
::
InitGflags
);
m
.
def
(
"init_glog"
,
framework
::
InitGLOG
);
m
.
def
(
"init_devices"
,
&
framework
::
InitDevices
);
m
.
def
(
"is_compile_gpu"
,
IsCompileGPU
);
...
...
python/paddle/v2/fluid/__init__.py
浏览文件 @
cd5fad13
...
...
@@ -27,7 +27,7 @@ __all__ = framework.__all__ + executor.__all__ + [
]
def
__
read_gflags_from_env
__
():
def
__
bootstrap
__
():
"""
Enable reading gflags from environment variables.
...
...
@@ -41,6 +41,7 @@ def __read_gflags_from_env__():
read_env_flags
.
append
(
'fraction_of_gpu_memory_to_use'
)
core
.
init_gflags
([
sys
.
argv
[
0
]]
+
[
"--tryfromenv="
+
","
.
join
(
read_env_flags
)])
core
.
init_glog
(
sys
.
argv
[
0
])
if
core
.
is_compile_gpu
():
core
.
init_devices
([
"CPU"
,
"GPU:0"
])
...
...
@@ -48,4 +49,4 @@ def __read_gflags_from_env__():
core
.
init_devices
([
"CPU"
])
__
read_gflags_from_env
__
()
__
bootstrap
__
()
python/paddle/v2/fluid/layers/ops.py
浏览文件 @
cd5fad13
from
..registry
import
register_layer
__all__
=
[
'mean'
,
'mul'
,
'dropout'
,
'reshape'
,
'sigmoid'
,
'scale'
,
'transpose'
,
'sigmoid_cross_entropy_with_logits'
,
'elementwise_add'
,
'elementwise_div'
,
'elementwise_sub'
,
'elementwise_mul'
,
'clip'
,
'abs'
,
'sequence_softmax'
__activations__
=
[
'abs'
,
'tanh'
,
'sigmoid'
,
'relu'
,
'sqrt'
,
'ceil'
,
'floor'
,
'log'
,
'round'
]
__all__
=
[
'mean'
,
'mul'
,
'dropout'
,
'reshape'
,
'scale'
,
'transpose'
,
'sigmoid_cross_entropy_with_logits'
,
'elementwise_add'
,
'elementwise_div'
,
'elementwise_sub'
,
'elementwise_mul'
,
'clip'
,
'sequence_softmax'
,
]
+
__activations__
for
_OP
in
set
(
__all__
):
globals
()[
_OP
]
=
register_layer
(
_OP
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录