Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
bdda08d9
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bdda08d9
编写于
3月 28, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sin
上级
2e577379
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
7 deletion
+39
-7
paddle/fluid/framework/CMakeLists.txt
paddle/fluid/framework/CMakeLists.txt
+1
-1
paddle/fluid/operators/activation_op.cc
paddle/fluid/operators/activation_op.cc
+21
-3
paddle/fluid/operators/activation_op.h
paddle/fluid/operators/activation_op.h
+1
-0
paddle/function/EigenGemm.cpp
paddle/function/EigenGemm.cpp
+0
-1
python/paddle/fluid/layers/ops.py
python/paddle/fluid/layers/ops.py
+1
-0
python/paddle/fluid/tests/unittests/test_activation_op.py
python/paddle/fluid/tests/unittests/test_activation_op.py
+15
-2
未找到文件。
paddle/fluid/framework/CMakeLists.txt
浏览文件 @
bdda08d9
...
...
@@ -100,7 +100,7 @@ cc_test(init_test SRCS init_test.cc DEPS init)
cc_test
(
op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_context framework_proto
)
cc_test
(
cow_ptr_tests SRCS details/cow_ptr_test.cc
)
cc_test
(
channel_test SRCS channel_test.cc
)
#
cc_test(channel_test SRCS channel_test.cc)
cc_test
(
tuple_test SRCS tuple_test.cc
)
cc_test
(
concurrency_test SRCS concurrency_test.cc DEPS go_op channel_close_op channel_create_op
channel_send_op channel_recv_op sum_op select_op elementwise_add_op compare_op
...
...
paddle/fluid/operators/activation_op.cc
浏览文件 @
bdda08d9
...
...
@@ -264,10 +264,10 @@ class CosOpMaker : public framework::OpProtoAndCheckerMaker {
public:
CosOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of
Floor
operator"
);
AddOutput
(
"Out"
,
"Output of
Floor
operator"
);
AddInput
(
"X"
,
"Input of
Cosine
operator"
);
AddOutput
(
"Out"
,
"Output of
Cosine
operator"
);
AddComment
(
R"DOC(
Floor
Activation Operator.
Cosine
Activation Operator.
$out = cos(x)$
...
...
@@ -275,6 +275,21 @@ $out = cos(x)$
}
};
class
SinOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
SinOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input of Sine operator"
);
AddOutput
(
"Out"
,
"Output of Sine operator"
);
AddComment
(
R"DOC(
Sine Activation Operator.
$out = sin(x)$
)DOC"
);
}
};
class
RoundOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
RoundOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
...
...
@@ -579,6 +594,9 @@ REGISTER_OP(floor, ops::ActivationOp, ops::FloorOpMaker, floor_grad,
REGISTER_OP
(
cos
,
ops
::
ActivationOp
,
ops
::
CosOpMaker
,
cos_grad
,
ops
::
ActivationOpGrad
);
REGISTER_OP
(
sin
,
ops
::
ActivationOp
,
ops
::
SinOpMaker
,
sin_grad
,
ops
::
ActivationOpGrad
);
REGISTER_OP
(
round
,
ops
::
ActivationOp
,
ops
::
RoundOpMaker
,
round_grad
,
ops
::
ActivationOpGrad
);
...
...
paddle/fluid/operators/activation_op.h
浏览文件 @
bdda08d9
...
...
@@ -831,6 +831,7 @@ struct SwishGradFunctor : public BaseActivationFunctor<T> {
__macro(ceil, CeilFunctor, ZeroGradFunctor); \
__macro(floor, FloorFunctor, ZeroGradFunctor); \
__macro(cos, CosFunctor, CosGradFunctor); \
__macro(sin, SinFunctor, SinGradFunctor); \
__macro(round, RoundFunctor, ZeroGradFunctor); \
__macro(reciprocal, ReciprocalFunctor, ReciprocalGradFunctor); \
__macro(log, LogFunctor, LogGradFunctor); \
...
...
paddle/function/EigenGemm.cpp
浏览文件 @
bdda08d9
...
...
@@ -63,7 +63,6 @@ struct EigenBlasGemm {
const
EigenMatrix
a
(
const_cast
<
T
*>
(
A
),
sizeA
);
const
EigenMatrix
b
(
const_cast
<
T
*>
(
B
),
sizeB
);
EigenMatrix
c
(
C
,
sizeC
);
Eigen
::
Tensor
<
T
,
2
,
Eigen
::
RowMajor
,
int
>
ss
;
typedef
typename
Eigen
::
Tensor
<
T
,
2
>::
DimensionPair
DimPair
;
Eigen
::
array
<
DimPair
,
1
>
dims
;
...
...
python/paddle/fluid/layers/ops.py
浏览文件 @
bdda08d9
...
...
@@ -26,6 +26,7 @@ __activations__ = [
'ceil'
,
'floor'
,
'cos'
,
'sin'
,
'round'
,
'reciprocal'
,
'log'
,
...
...
python/paddle/fluid/tests/unittests/test_activation_op.py
浏览文件 @
bdda08d9
...
...
@@ -14,7 +14,6 @@
import
unittest
import
numpy
as
np
import
math
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
scipy.special
import
expit
...
...
@@ -202,7 +201,21 @@ class TestCos(OpTest):
self
.
op_type
=
"cos"
x
=
np
.
random
.
uniform
(
-
1
,
1
,
[
4
,
4
]).
astype
(
"float32"
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
math
.
cos
(
self
.
inputs
[
'X'
])}
self
.
outputs
=
{
'Out'
:
np
.
cos
(
self
.
inputs
[
'X'
])}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
max_relative_error
=
0.007
)
class
TestSin
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"sin"
x
=
np
.
random
.
uniform
(
-
1
,
1
,
[
4
,
4
]).
astype
(
"float32"
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
np
.
sin
(
self
.
inputs
[
'X'
])}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录