Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8a40497a
提交
8a40497a
authored
3月 16, 2011
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some cleanup
上级
f95435ea
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
14 行删除
+12
-14
basic.py
theano/tensor/basic.py
+4
-4
elemwise.py
theano/tensor/elemwise.py
+8
-10
没有找到文件。
theano/tensor/basic.py
浏览文件 @
8a40497a
...
@@ -2004,7 +2004,7 @@ def round(a, mode="half_away_from_zero"):
...
@@ -2004,7 +2004,7 @@ def round(a, mode="half_away_from_zero"):
else
:
else
:
raise
Exception
(
"round mode
%
s is not implemented."
%
mode
)
raise
Exception
(
"round mode
%
s is not implemented."
%
mode
)
@_scal_elemwise_with_nfunc
(
'around'
,
1
,
0
)
@_scal_elemwise_with_nfunc
(
'around'
,
1
,
-
1
)
def
round_half_to_even
(
a
):
def
round_half_to_even
(
a
):
"""round_half_to_even(a)"""
"""round_half_to_even(a)"""
...
@@ -2052,15 +2052,15 @@ def erf(a):
...
@@ -2052,15 +2052,15 @@ def erf(a):
def
erfc
(
a
):
def
erfc
(
a
):
"""complementary error function"""
"""complementary error function"""
@_scal_elemwise_with_nfunc
(
'real'
,
1
,
0
)
@_scal_elemwise_with_nfunc
(
'real'
,
1
,
-
1
)
def
real
(
z
):
def
real
(
z
):
"""Return real component of complex-valued tensor `z`"""
"""Return real component of complex-valued tensor `z`"""
@_scal_elemwise_with_nfunc
(
'imag'
,
1
,
0
)
@_scal_elemwise_with_nfunc
(
'imag'
,
1
,
-
1
)
def
imag
(
z
):
def
imag
(
z
):
"""Return imaginary component of complex-valued tensor `z`"""
"""Return imaginary component of complex-valued tensor `z`"""
@_scal_elemwise_with_nfunc
(
'angle'
,
1
,
0
)
@_scal_elemwise_with_nfunc
(
'angle'
,
1
,
-
1
)
def
angle
(
z
):
def
angle
(
z
):
"""Return polar-coordinate angle of complex-valued tensor `z`"""
"""Return polar-coordinate angle of complex-valued tensor `z`"""
...
...
theano/tensor/elemwise.py
浏览文件 @
8a40497a
...
@@ -361,10 +361,6 @@ class DimShufflePrinter:
...
@@ -361,10 +361,6 @@ class DimShufflePrinter:
pprint
.
assign
(
lambda
pstate
,
r
:
r
.
owner
and
isinstance
(
r
.
owner
.
op
,
DimShuffle
),
DimShufflePrinter
())
pprint
.
assign
(
lambda
pstate
,
r
:
r
.
owner
and
isinstance
(
r
.
owner
.
op
,
DimShuffle
),
DimShufflePrinter
())
def
_make_nfunc
(
name
,
nin
,
nout
):
f
=
getattr
(
numpy
,
name
)
return
f
################
################
### Elemwise ###
### Elemwise ###
...
@@ -408,11 +404,13 @@ class Elemwise(Op):
...
@@ -408,11 +404,13 @@ class Elemwise(Op):
the input's storage. (Just like destroymap, but without the lists.)
the input's storage. (Just like destroymap, but without the lists.)
* nfunc_spec: either None or a tuple of three elements, (nfunc_name, nin, nout) such
* nfunc_spec: either None or a tuple of three elements, (nfunc_name, nin, nout) such
that getattr(numpy, nfunc_name) implements this operation, takes nin
that getattr(numpy, nfunc_name) implements this operation, takes nin
inputs and
nout **destination** outputs (nout ==
0 if the numpy function
inputs and
abs(nout) outputs (nout <
0 if the numpy function
does not provide the option of providing a numpy array to store the
does not provide the option of providing a numpy array to store the
results in). Note that nin cannot always be inferred from the scalar op's
results in). Note that nin cannot always be inferred from the scalar op's
own nin field because that value is sometimes 0 (meaning a variable number
own nin field because that value is sometimes 0 (meaning a variable number
of inputs), whereas the numpy function may not have varargs.
of inputs), whereas the numpy function may not have varargs. NOTE: as of
now, the sign of the nout field is ignored (some work needs to be done
to resize the destinations when needed).
"""
"""
self
.
name
=
name
self
.
name
=
name
self
.
scalar_op
=
scalar_op
self
.
scalar_op
=
scalar_op
...
@@ -423,7 +421,7 @@ class Elemwise(Op):
...
@@ -423,7 +421,7 @@ class Elemwise(Op):
self
.
nfunc
=
None
self
.
nfunc
=
None
self
.
nfunc_spec
=
nfunc_spec
self
.
nfunc_spec
=
nfunc_spec
if
nfunc_spec
:
if
nfunc_spec
:
self
.
nfunc
=
_make_nfunc
(
*
nfunc_spec
)
self
.
nfunc
=
getattr
(
numpy
,
nfunc_spec
[
0
]
)
elif
scalar_op
.
nin
>
0
:
elif
scalar_op
.
nin
>
0
:
self
.
ufunc
=
numpy
.
frompyfunc
(
scalar_op
.
impl
,
scalar_op
.
nin
,
scalar_op
.
nout
)
self
.
ufunc
=
numpy
.
frompyfunc
(
scalar_op
.
impl
,
scalar_op
.
nin
,
scalar_op
.
nout
)
...
@@ -443,7 +441,7 @@ class Elemwise(Op):
...
@@ -443,7 +441,7 @@ class Elemwise(Op):
self
.
ufunc
=
None
self
.
ufunc
=
None
self
.
nfunc
=
None
self
.
nfunc
=
None
if
getattr
(
self
,
'nfunc_spec'
,
None
):
if
getattr
(
self
,
'nfunc_spec'
,
None
):
self
.
nfunc
=
_make_nfunc
(
*
self
.
nfunc_spec
)
self
.
nfunc
=
getattr
(
numpy
,
self
.
nfunc_spec
[
0
]
)
elif
self
.
scalar_op
.
nin
>
0
:
elif
self
.
scalar_op
.
nin
>
0
:
self
.
ufunc
=
numpy
.
frompyfunc
(
self
.
scalar_op
.
impl
,
self
.
scalar_op
.
nin
,
self
.
scalar_op
.
nout
)
self
.
ufunc
=
numpy
.
frompyfunc
(
self
.
scalar_op
.
impl
,
self
.
scalar_op
.
nin
,
self
.
scalar_op
.
nout
)
self
.
_rehash
()
self
.
_rehash
()
...
@@ -645,8 +643,8 @@ class Elemwise(Op):
...
@@ -645,8 +643,8 @@ class Elemwise(Op):
if
self
.
nfunc
and
len
(
inputs
)
==
self
.
nfunc_spec
[
1
]:
if
self
.
nfunc
and
len
(
inputs
)
==
self
.
nfunc_spec
[
1
]:
ufunc
=
self
.
nfunc
ufunc
=
self
.
nfunc
nout
=
self
.
nfunc_spec
[
2
]
nout
=
self
.
nfunc_spec
[
2
]
if
nout
==
0
:
if
nout
<
0
:
nout
=
1
nout
=
-
nout
# Unfortunately, the else case does not allow us to
# Unfortunately, the else case does not allow us to
# directly feed the destination arguments to the nfunc
# directly feed the destination arguments to the nfunc
# since it sometimes requires resizing. Doing this
# since it sometimes requires resizing. Doing this
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论