Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
35a37e39
提交
35a37e39
authored
6月 04, 2012
作者:
Nicolas Bouchard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Wrap arccosh from numpy, elemwise.
上级
d3479239
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
50 行增加
和
2 行删除
+50
-2
basic.py
theano/scalar/basic.py
+19
-0
basic.py
theano/tensor/basic.py
+6
-0
inplace.py
theano/tensor/inplace.py
+4
-0
test_basic.py
theano/tensor/tests/test_basic.py
+21
-2
没有找到文件。
theano/scalar/basic.py
浏览文件 @
35a37e39
...
@@ -2116,6 +2116,25 @@ class Cosh(UnaryScalarOp):
...
@@ -2116,6 +2116,25 @@ class Cosh(UnaryScalarOp):
cosh
=
Cosh
(
upgrade_to_float
,
name
=
'cosh'
)
cosh
=
Cosh
(
upgrade_to_float
,
name
=
'cosh'
)
class
ArcCosh
(
UnaryScalarOp
):
def
impl
(
self
,
x
):
return
numpy
.
arccosh
(
x
)
def
grad
(
self
,
(
x
,
),
(
gz
,
)):
if
x
.
type
in
complex_types
:
raise
NotImplementedError
()
if
x
.
type
in
float_types
:
return
gz
/
sqrt
(
sqr
(
x
)
-
numpy
.
cast
[
x
.
type
](
1
)),
else
:
return
None
,
def
c_code
(
self
,
node
,
name
,
(
x
,
),
(
z
,
),
sub
):
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
raise
NotImplementedError
(
'type not supported'
,
type
)
return
"
%(z)
s = acosh(
%(x)
s);"
%
locals
()
arccosh
=
ArcCosh
(
upgrade_to_float
,
name
=
'arccosh'
)
class
Sinh
(
UnaryScalarOp
):
class
Sinh
(
UnaryScalarOp
):
"""
"""
sinh(x) = (exp(x) - exp(-x)) / 2
sinh(x) = (exp(x) - exp(-x)) / 2
...
...
theano/tensor/basic.py
浏览文件 @
35a37e39
...
@@ -2585,6 +2585,7 @@ def arcsin(a):
...
@@ -2585,6 +2585,7 @@ def arcsin(a):
def
tan
(
a
):
def
tan
(
a
):
"""tangent of a"""
"""tangent of a"""
@_scal_elemwise_with_nfunc
(
'arctan'
,
1
,
1
)
@_scal_elemwise_with_nfunc
(
'arctan'
,
1
,
1
)
def
arctan
(
a
):
def
arctan
(
a
):
"""arctangent of a"""
"""arctangent of a"""
...
@@ -2595,6 +2596,11 @@ def cosh(a):
...
@@ -2595,6 +2596,11 @@ def cosh(a):
"""hyperbolic cosine of a"""
"""hyperbolic cosine of a"""
@_scal_elemwise_with_nfunc
(
'arccosh'
,
1
,
1
)
def
arccosh
(
a
):
"""hyperbolic arc cosine of a"""
@_scal_elemwise_with_nfunc
(
'sinh'
,
1
,
1
)
@_scal_elemwise_with_nfunc
(
'sinh'
,
1
,
1
)
def
sinh
(
a
):
def
sinh
(
a
):
"""hyperbolic sine of a"""
"""hyperbolic sine of a"""
...
...
theano/tensor/inplace.py
浏览文件 @
35a37e39
...
@@ -167,6 +167,10 @@ def arctan_inplace(a):
...
@@ -167,6 +167,10 @@ def arctan_inplace(a):
def
cosh_inplace
(
a
):
def
cosh_inplace
(
a
):
"""hyperbolic cosine of `a` (inplace on `a`)"""
"""hyperbolic cosine of `a` (inplace on `a`)"""
@_scal_inplace
def
arccosh_inplace
(
a
):
"""hyperbolic arc cosine of `a` (inplace on `a`)"""
@_scal_inplace
@_scal_inplace
def
sinh_inplace
(
a
):
def
sinh_inplace
(
a
):
"""hyperbolic sine of `a` (inplace on `a`)"""
"""hyperbolic sine of `a` (inplace on `a`)"""
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
35a37e39
...
@@ -1069,6 +1069,8 @@ CosInplaceTester = makeBroadcastTester(op = inplace.cos_inplace,
...
@@ -1069,6 +1069,8 @@ CosInplaceTester = makeBroadcastTester(op = inplace.cos_inplace,
good
=
_good_broadcast_unary_wide
,
good
=
_good_broadcast_unary_wide
,
grad
=
_grad_broadcast_unary_wide
,
grad
=
_grad_broadcast_unary_wide
,
inplace
=
True
)
inplace
=
True
)
ArccosTester
=
makeBroadcastTester
(
op
=
tensor
.
arccos
,
ArccosTester
=
makeBroadcastTester
(
op
=
tensor
.
arccos
,
expected
=
numpy
.
arccos
,
expected
=
numpy
.
arccos
,
good
=
_good_broadcast_unary_arccos
,
good
=
_good_broadcast_unary_arccos
,
...
@@ -1107,8 +1109,6 @@ ArctanTester = makeBroadcastTester(op = tensor.tan,
...
@@ -1107,8 +1109,6 @@ ArctanTester = makeBroadcastTester(op = tensor.tan,
good
=
_good_broadcast_unary_wide
,
good
=
_good_broadcast_unary_wide
,
grad
=
_grad_broadcast_unary_wide
,
grad
=
_grad_broadcast_unary_wide
,
grad_rtol
=
tan_grad_rtol
)
grad_rtol
=
tan_grad_rtol
)
ArctanInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
tan_inplace
,
ArctanInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
tan_inplace
,
expected
=
numpy
.
tan
,
expected
=
numpy
.
tan
,
good
=
_good_broadcast_unary_wide
,
good
=
_good_broadcast_unary_wide
,
...
@@ -1127,6 +1127,25 @@ CoshInplaceTester = makeBroadcastTester(op = inplace.cosh_inplace,
...
@@ -1127,6 +1127,25 @@ CoshInplaceTester = makeBroadcastTester(op = inplace.cosh_inplace,
grad
=
_grad_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
inplace
=
True
)
inplace
=
True
)
_good_broadcast_unary_arccosh
=
dict
(
normal
=
(
rand_ranged
(
1
,
1000
,
(
2
,
3
)),),
integers
=
(
randint_ranged
(
1
,
1000
,
(
2
,
3
)),),
complex
=
(
randc128_ranged
(
1
,
1000
,
(
2
,
3
)),),
empty
=
(
numpy
.
asarray
([]),),)
_grad_broadcast_unary_arccosh
=
dict
(
normal
=
(
rand_ranged
(
1
,
1000
,
(
2
,
3
)),),)
ArccoshTester
=
makeBroadcastTester
(
op
=
tensor
.
arccosh
,
expected
=
numpy
.
arccosh
,
good
=
_good_broadcast_unary_arccosh
,
grad
=
_grad_broadcast_unary_arccosh
)
ArccoshInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
arccosh_inplace
,
expected
=
numpy
.
arccosh
,
good
=
_good_broadcast_unary_arccosh
,
grad
=
_grad_broadcast_unary_arccosh
,
inplace
=
True
)
SinhTester
=
makeBroadcastTester
(
op
=
tensor
.
sinh
,
SinhTester
=
makeBroadcastTester
(
op
=
tensor
.
sinh
,
expected
=
numpy
.
sinh
,
expected
=
numpy
.
sinh
,
good
=
_good_broadcast_unary_normal
,
good
=
_good_broadcast_unary_normal
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论