Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0ef2abb8
提交
0ef2abb8
authored
2月 02, 2012
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Re-using lists of types already defined in tensor
Similar lists were added recently in elemwise.py: it is better to re-use existing ones.
上级
fda86e28
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
13 行增加
和
16 行删除
+13
-16
basic.py
theano/tensor/basic.py
+3
-2
elemwise.py
theano/tensor/elemwise.py
+2
-6
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+8
-8
没有找到文件。
theano/tensor/basic.py
浏览文件 @
0ef2abb8
...
@@ -37,9 +37,10 @@ python_any = any
...
@@ -37,9 +37,10 @@ python_any = any
python_all
=
all
python_all
=
all
# Define common subsets of dtypes (as strings).
# Define common subsets of dtypes (as strings).
int_dtypes
=
map
(
str
,
scal
.
int_types
)
discrete_dtypes
=
map
(
str
,
scal
.
discrete_types
)
complex_dtypes
=
map
(
str
,
scal
.
complex_types
)
complex_dtypes
=
map
(
str
,
scal
.
complex_types
)
continuous_dtypes
=
map
(
str
,
scal
.
continuous_types
)
discrete_dtypes
=
map
(
str
,
scal
.
discrete_types
)
int_dtypes
=
map
(
str
,
scal
.
int_types
)
class
ShapeError
(
Exception
):
class
ShapeError
(
Exception
):
...
...
theano/tensor/elemwise.py
浏览文件 @
0ef2abb8
...
@@ -13,7 +13,6 @@ from theano.gof.python25 import all, any
...
@@ -13,7 +13,6 @@ from theano.gof.python25 import all, any
config
=
theano
.
config
config
=
theano
.
config
# tensor depends on elemwise to provide definitions for several ops
# tensor depends on elemwise to provide definitions for several ops
# but elemwise needs to make TensorType instances, so we have these as
# but elemwise needs to make TensorType instances, so we have these as
# placeholders and the tensor module fills them
# placeholders and the tensor module fills them
...
@@ -29,10 +28,6 @@ def TensorVariable(*inputs, **kwargs):
...
@@ -29,10 +28,6 @@ def TensorVariable(*inputs, **kwargs):
def
TensorConstant
(
*
inputs
,
**
kwargs
):
def
TensorConstant
(
*
inputs
,
**
kwargs
):
raise
Exception
(
"Circular dependencies prevent using this here. import tensor before elemwise"
)
raise
Exception
(
"Circular dependencies prevent using this here. import tensor before elemwise"
)
# Define common subsets of dtypes (as strings).
discrete_dtypes
=
map
(
str
,
scalar
.
discrete_types
)
continuous_dtypes
=
map
(
str
,
scalar
.
continuous_types
)
##################
##################
### DimShuffle ###
### DimShuffle ###
...
@@ -1374,7 +1369,8 @@ class CAReduceDtype(CAReduce):
...
@@ -1374,7 +1369,8 @@ class CAReduceDtype(CAReduce):
uint16
=
'uint64'
,
uint16
=
'uint64'
,
uint32
=
'uint64'
,
uint32
=
'uint64'
,
)
.
get
(
idtype
,
idtype
)
)
.
get
(
idtype
,
idtype
)
elif
dtype
in
continuous_dtypes
and
idtype
in
discrete_dtypes
:
elif
(
dtype
in
theano
.
tensor
.
continuous_dtypes
and
idtype
in
theano
.
tensor
.
discrete_dtypes
):
# Specifying a continuous output for discrete input is OK
# Specifying a continuous output for discrete input is OK
return
dtype
return
dtype
else
:
else
:
...
...
theano/tensor/tests/test_elemwise.py
浏览文件 @
0ef2abb8
...
@@ -534,8 +534,8 @@ class T_sum_dtype(unittest.TestCase):
...
@@ -534,8 +534,8 @@ class T_sum_dtype(unittest.TestCase):
# We always allow int/uint inputs with float/complex outputs.
# We always allow int/uint inputs with float/complex outputs.
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
output_dtype
)
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
output_dtype
)
if
(
output_dtype
==
upcasted_dtype
or
if
(
output_dtype
==
upcasted_dtype
or
(
input_dtype
in
discrete_dtypes
and
(
input_dtype
in
tensor
.
discrete_dtypes
and
output_dtype
in
continuous_dtypes
)
output_dtype
in
tensor
.
continuous_dtypes
)
):
):
sum_var
=
x
.
sum
(
dtype
=
output_dtype
,
axis
=
axis
)
sum_var
=
x
.
sum
(
dtype
=
output_dtype
,
axis
=
axis
)
assert
sum_var
.
dtype
==
output_dtype
assert
sum_var
.
dtype
==
output_dtype
...
@@ -559,7 +559,7 @@ class T_mean_dtype(unittest.TestCase):
...
@@ -559,7 +559,7 @@ class T_mean_dtype(unittest.TestCase):
for
idx
,
dtype
in
enumerate
(
imap
(
str
,
theano
.
scalar
.
all_types
)):
for
idx
,
dtype
in
enumerate
(
imap
(
str
,
theano
.
scalar
.
all_types
)):
axis
=
axes
[
idx
%
len
(
axes
)]
axis
=
axes
[
idx
%
len
(
axes
)]
x
=
tensor
.
matrix
(
dtype
=
dtype
)
.
mean
(
axis
=
axis
)
x
=
tensor
.
matrix
(
dtype
=
dtype
)
.
mean
(
axis
=
axis
)
if
dtype
in
discrete_dtypes
:
if
dtype
in
tensor
.
discrete_dtypes
:
assert
x
.
dtype
==
'float64'
assert
x
.
dtype
==
'float64'
else
:
else
:
assert
x
.
dtype
==
dtype
,
(
x
,
x
.
dtype
,
dtype
)
assert
x
.
dtype
==
dtype
,
(
x
,
x
.
dtype
,
dtype
)
...
@@ -582,7 +582,7 @@ class T_mean_dtype(unittest.TestCase):
...
@@ -582,7 +582,7 @@ class T_mean_dtype(unittest.TestCase):
pass
pass
else
:
else
:
# Executed if no TypeError was raised
# Executed if no TypeError was raised
if
sum_dtype
in
discrete_dtypes
:
if
sum_dtype
in
tensor
.
discrete_dtypes
:
assert
mean_var
.
dtype
==
'float64'
,
(
mean_var
.
dtype
,
sum_dtype
)
assert
mean_var
.
dtype
==
'float64'
,
(
mean_var
.
dtype
,
sum_dtype
)
else
:
else
:
assert
mean_var
.
dtype
==
sum_dtype
,
(
mean_var
.
dtype
,
output_dtype
)
assert
mean_var
.
dtype
==
sum_dtype
,
(
mean_var
.
dtype
,
output_dtype
)
...
@@ -635,8 +635,8 @@ class T_prod_dtype(unittest.TestCase):
...
@@ -635,8 +635,8 @@ class T_prod_dtype(unittest.TestCase):
# We always allow int/uint inputs with float/complex outputs.
# We always allow int/uint inputs with float/complex outputs.
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
output_dtype
)
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
output_dtype
)
if
(
output_dtype
==
upcasted_dtype
or
if
(
output_dtype
==
upcasted_dtype
or
(
input_dtype
in
discrete_dtypes
and
(
input_dtype
in
tensor
.
discrete_dtypes
and
output_dtype
in
continuous_dtypes
)
output_dtype
in
tensor
.
continuous_dtypes
)
):
):
prod_var
=
x
.
prod
(
dtype
=
output_dtype
,
axis
=
axis
)
prod_var
=
x
.
prod
(
dtype
=
output_dtype
,
axis
=
axis
)
assert
prod_var
.
dtype
==
output_dtype
assert
prod_var
.
dtype
==
output_dtype
...
@@ -684,8 +684,8 @@ class T_prod_without_zeros_dtype(unittest.TestCase):
...
@@ -684,8 +684,8 @@ class T_prod_without_zeros_dtype(unittest.TestCase):
# We always allow int/uint inputs with float/complex outputs.
# We always allow int/uint inputs with float/complex outputs.
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
output_dtype
)
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
output_dtype
)
if
(
output_dtype
==
upcasted_dtype
or
if
(
output_dtype
==
upcasted_dtype
or
(
input_dtype
in
discrete_dtypes
and
(
input_dtype
in
tensor
.
discrete_dtypes
and
output_dtype
in
continuous_dtypes
)
output_dtype
in
tensor
.
continuous_dtypes
)
):
):
prod_woz_var
=
ProdWithoutZeros
(
prod_woz_var
=
ProdWithoutZeros
(
axis
=
axis
,
dtype
=
output_dtype
)(
x
)
axis
=
axis
,
dtype
=
output_dtype
)(
x
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论