Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
61c52438
提交
61c52438
authored
6月 05, 2012
作者:
Nicolas Bouchard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Wrap arctan2 from numpy, elemwise.
上级
8aefb2f5
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
65 行增加
和
4 行删除
+65
-4
basic.py
theano/scalar/basic.py
+21
-0
basic.py
theano/tensor/basic.py
+5
-0
inplace.py
theano/tensor/inplace.py
+4
-0
test_basic.py
theano/tensor/tests/test_basic.py
+35
-4
没有找到文件。
theano/scalar/basic.py
浏览文件 @
61c52438
...
@@ -2113,6 +2113,27 @@ class ArcTan(UnaryScalarOp):
...
@@ -2113,6 +2113,27 @@ class ArcTan(UnaryScalarOp):
arctan
=
ArcTan
(
upgrade_to_float
,
name
=
'arctan'
)
arctan
=
ArcTan
(
upgrade_to_float
,
name
=
'arctan'
)
class
ArcTan2
(
BinaryScalarOp
):
def
impl
(
self
,
y
,
x
):
return
numpy
.
arctan2
(
y
,
x
)
def
grad
(
self
,
(
y
,
x
),
(
gz
,)):
if
gz
.
type
in
complex_types
:
raise
NotImplementedError
()
if
x
.
type
in
float_types
and
y
.
type
in
float_types
:
return
[
gz
*
x
/
(
sqr
(
x
)
+
sqr
(
y
)),
gz
*
neg
(
y
)
/
(
sqr
(
x
)
+
sqr
(
y
))]
else
:
return
None
,
def
c_code
(
self
,
node
,
name
,
(
y
,
x
),
(
z
,),
sub
):
if
(
node
.
inputs
[
0
]
.
type
in
complex_types
or
node
.
inputs
[
1
]
.
type
in
complex_types
):
raise
NotImplementedError
(
'type not supported'
,
type
)
return
"
%(z)
s = atan2(
%(y)
s,
%(x)
s);"
%
locals
()
arctan2
=
ArcTan2
(
upgrade_to_float
,
name
=
'arctan2'
)
class
Cosh
(
UnaryScalarOp
):
class
Cosh
(
UnaryScalarOp
):
"""
"""
cosh(x) = (exp(x) + exp(-x)) / 2
cosh(x) = (exp(x) + exp(-x)) / 2
...
...
theano/tensor/basic.py
浏览文件 @
61c52438
...
@@ -2596,6 +2596,11 @@ def arctan(a):
...
@@ -2596,6 +2596,11 @@ def arctan(a):
"""arctangent of a"""
"""arctangent of a"""
@_scal_elemwise_with_nfunc
(
'arctan2'
,
1
,
1
)
def
arctan2
(
a
,
b
):
"""arctangent of a / b"""
@_scal_elemwise_with_nfunc
(
'cosh'
,
1
,
1
)
@_scal_elemwise_with_nfunc
(
'cosh'
,
1
,
1
)
def
cosh
(
a
):
def
cosh
(
a
):
"""hyperbolic cosine of a"""
"""hyperbolic cosine of a"""
...
...
theano/tensor/inplace.py
浏览文件 @
61c52438
...
@@ -167,6 +167,10 @@ def tan_inplace(a):
...
@@ -167,6 +167,10 @@ def tan_inplace(a):
def
arctan_inplace
(
a
):
def
arctan_inplace
(
a
):
"""arctangent of `a` (inplace on `a`)"""
"""arctangent of `a` (inplace on `a`)"""
@_scal_inplace
def
arctan2_inplace
(
a
,
b
):
"""arctangent of `a` / `b` (inplace on `a`)"""
@_scal_inplace
@_scal_inplace
def
cosh_inplace
(
a
):
def
cosh_inplace
(
a
):
"""hyperbolic cosine of `a` (inplace on `a`)"""
"""hyperbolic cosine of `a` (inplace on `a`)"""
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
61c52438
...
@@ -1103,18 +1103,49 @@ TanInplaceTester = makeBroadcastTester(op=inplace.tan_inplace,
...
@@ -1103,18 +1103,49 @@ TanInplaceTester = makeBroadcastTester(op=inplace.tan_inplace,
grad_rtol
=
tan_grad_rtol
,
grad_rtol
=
tan_grad_rtol
,
inplace
=
True
)
inplace
=
True
)
ArcTanTester
=
makeBroadcastTester
(
op
=
tensor
.
tan
,
ArcTanTester
=
makeBroadcastTester
(
op
=
tensor
.
arc
tan
,
expected
=
numpy
.
tan
,
expected
=
numpy
.
arc
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
.
arc
tan_inplace
,
expected
=
numpy
.
tan
,
expected
=
numpy
.
arc
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
,
inplace
=
True
)
inplace
=
True
)
_good_broadcast_binary_arctan2
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
not_same_dimensions
=
(
rand
(
2
,
2
),
rand
(
2
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
integers
=
(
randint
(
2
,
3
),
randint
(
2
,
3
)),
dtype_mixup_1
=
(
rand
(
2
,
3
),
randint
(
2
,
3
)),
dtype_mixup_2
=
(
randint
(
2
,
3
),
rand
(
2
,
3
)),
empty
=
(
numpy
.
asarray
([]),
numpy
.
asarray
([
1
])),
)
_grad_broadcast_binary_arctan2
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
)
ArcTan2Tester
=
makeBroadcastTester
(
op
=
tensor
.
arctan2
,
expected
=
numpy
.
arctan2
,
good
=
_good_broadcast_binary_arctan2
,
grad
=
_grad_broadcast_binary_arctan2
,
grad_rtol
=
tan_grad_rtol
)
ArcTan2InplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
arctan2_inplace
,
expected
=
numpy
.
arctan2
,
good
=
_good_broadcast_binary_arctan2
,
grad
=
_grad_broadcast_binary_arctan2
,
grad_rtol
=
tan_grad_rtol
,
inplace
=
True
)
CoshTester
=
makeBroadcastTester
(
op
=
tensor
.
cosh
,
CoshTester
=
makeBroadcastTester
(
op
=
tensor
.
cosh
,
expected
=
numpy
.
cosh
,
expected
=
numpy
.
cosh
,
good
=
_good_broadcast_unary_normal
,
good
=
_good_broadcast_unary_normal
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论