Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a8ce3207
提交
a8ce3207
authored
7月 30, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Catch only exception.
上级
d7515eaf
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
8 行删除
+8
-8
basic.py
theano/tensor/basic.py
+8
-8
没有找到文件。
theano/tensor/basic.py
浏览文件 @
a8ce3207
...
...
@@ -158,7 +158,7 @@ def as_tensor_variable(x, name=None, ndim=None):
except
TypeError
:
try
:
str_x
=
str
(
x
)
except
:
except
Exception
,
e
:
str_x
=
repr
(
x
)
raise
TypeError
(
"Cannot convert
%
s to TensorType"
%
str_x
,
type
(
x
))
...
...
@@ -340,7 +340,7 @@ def constant_or_value(x, rtype, name=None, ndim=None, dtype=None):
else
:
# leave the shape out of the type
return
rtype
(
TensorType
(
dtype
=
x_
.
dtype
,
broadcastable
=
bcastable
),
x_
,
name
=
name
)
except
:
except
Exception
:
raise
TypeError
(
"Could not convert
%
s to TensorType"
%
x
,
type
(
x
))
def
constant
(
x
,
name
=
None
,
ndim
=
None
,
dtype
=
None
):
...
...
@@ -425,7 +425,7 @@ def get_constant_value(v):
try
:
numpy
.
complex
(
data
)
#works for all numeric scalars
return
data
except
:
except
Exception
:
raise
TypeError
(
'v.data is non-numeric, non-scalar, or has more than one unique value'
,
v
)
if
v
.
owner
:
if
isinstance
(
v
.
owner
.
op
,
Alloc
):
...
...
@@ -1361,7 +1361,7 @@ class TensorConstantSignature(tuple):
return
False
try
:
(
t0
,
d0
),
(
t1
,
d1
)
=
self
,
other
except
:
except
Exception
,
e
:
return
False
#N.B. compare shape to ensure no broadcasting in ==
if
t0
!=
t1
or
d0
.
shape
!=
d1
.
shape
:
...
...
@@ -1994,7 +1994,7 @@ def max(x, axis='DEFAULT'):
try
:
const
=
get_constant_value
(
axis
)
return
CAReduce
(
scal
.
maximum
,
list
(
const
))(
x
)
except
:
except
Exception
:
return
max_and_argmax
(
x
,
axis
)[
0
]
@constructor
...
...
@@ -2873,7 +2873,7 @@ def extract_constant(x):
'''
try
:
x
=
get_constant_value
(
x
)
except
:
except
Exception
:
pass
if
isinstance
(
x
,
scal
.
ScalarVariable
):
if
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
ScalarFromTensor
):
...
...
@@ -4398,7 +4398,7 @@ class Reshape(Op):
', should be
%
i'
%
(
len
(
shp
),
self
.
ndim
),
shp
)
try
:
out
[
0
]
=
numpy
.
reshape
(
x
,
shp
)
except
:
except
Exception
,
e
:
raise
ValueError
(
'Cannot reshape input of shape
%
s to shape
%
s'
%
(
x
.
shape
,
shp
))
def
grad
(
self
,
inp
,
grads
):
x
,
shp
=
inp
...
...
@@ -4593,7 +4593,7 @@ class ARange(Op):
try
:
v
=
get_constant_value
(
var
)
return
numpy
.
all
(
v
==
value
)
except
:
except
Exception
:
pass
return
False
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论