Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
757d0483
提交
757d0483
authored
5月 13, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tensor basic - replaced complex Ops with true Elemwise ones.
上级
437d05c4
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
78 行删除
+15
-78
basic.py
theano/tensor/basic.py
+15
-78
没有找到文件。
theano/tensor/basic.py
浏览文件 @
757d0483
...
@@ -1629,88 +1629,25 @@ def sinh(a):
...
@@ -1629,88 +1629,25 @@ def sinh(a):
def
tanh
(
a
):
def
tanh
(
a
):
"""hyperbolic tangent of a"""
"""hyperbolic tangent of a"""
class
Real
(
Op
):
@_scal_elemwise
"""Extract the real elements of a complex ndarray"""
def
real
(
z
):
view_map
=
{
0
:[
0
]}
"""Return real component of complex-valued tensor `z`"""
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
make_node
(
self
,
x
):
_x
=
as_tensor
(
x
)
y_dtype
=
_x
.
type
.
dtype
if
y_dtype
==
'complex64'
:
y_dtype
=
'float32'
if
y_dtype
==
'complex128'
:
y_dtype
=
'float64'
_y
=
Tensor
(
y_dtype
,
_x
.
type
.
broadcastable
)()
return
Apply
(
self
,
[
_x
],
[
_y
])
def
perform
(
self
,
node
,
(
x
,),
(
y
,)):
if
str
(
x
.
dtype
)
.
startswith
(
'complex'
):
y
[
0
]
=
x
.
real
else
:
y
[
0
]
=
x
def
grad
(
self
,
inputs
,
(
g_y
,)):
#TODO: waiting on a Complex(real=, imag=) op that can merge
#things back into a complex tensor
raise
NotImplementedError
()
_real
=
Real
()
@constructor
def
real
(
x
):
"""Return the real part of real or complex-valued `x`
For real-valued `x`, `x` itself is returned.
"""
_x
=
as_tensor_variable
(
x
)
if
_x
.
type
.
dtype
.
startswith
(
'complex'
):
return
_real
(
x
)
else
:
return
_x
class
Imag
(
Op
):
@_scal_elemwise
"""Extract the imaginary elements of a complex ndarray"""
def
imag
(
z
):
view_map
=
{
0
:[
0
]}
"""Return imaginary component of complex-valued tensor `z`"""
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
make_node
(
self
,
x
):
_x
=
as_tensor_variable
(
x
)
if
not
_x
.
type
.
dtype
.
startswith
(
'complex'
):
raise
TypeError
(
'Imag(x) requires complex x'
,
x
)
if
_x
.
type
.
dtype
==
'complex64'
:
y_dtype
=
'float32'
elif
_x
.
type
.
dtype
==
'complex128'
:
y_dtype
=
'float64'
else
:
raise
NotImplementedError
(
'what is this?'
,
y_dtype
)
_y
=
Tensor
(
y_dtype
,
_x
.
type
.
broadcastable
)()
return
Apply
(
self
,
[
_x
],
[
_y
])
def
perform
(
self
,
node
,
(
x
,),
(
y
,)):
if
str
(
x
.
dtype
)
.
startswith
(
'complex'
):
y
[
0
]
=
x
.
imag
else
:
y
[
0
]
=
x
*
0
def
grad
(
self
,
inputs
,
(
g_y
,)):
# TODO: waiting on a complex(real=, imag=) op that can merge
# things back into a complex tensor
raise
NotImplementedError
()
_imag
=
Imag
()
@constructor
def
imag
(
x
):
"""Return the imaginary part of real or complex-valued `x`
For real-valued 'x' this returns `zeros_like(x)`.
@_scal_elemwise
"""
def
angle
(
z
):
_x
=
as_tensor_variable
(
x
)
"""Return polar-coordinate angle of complex-valued tensor `z`"""
if
_x
.
type
.
dtype
.
startswith
(
'complex'
):
return
_imag
(
x
)
else
:
return
zeros_like
(
x
)
@constructor
@_scal_elemwise
def
angle
(
x
):
def
complex
(
real
,
imag
):
"""Return the angular component of complex-valued `x`"""
"""Return complex-valued tensor with `real` and `imag` components"""
raise
NotImplementedError
()
@_scal_elemwise
def
complex_from_polar
(
abs
,
angle
):
"""Return complex-valued tensor from polar coordinate specification"""
##########################
##########################
# Misc
# Misc
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论