Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
29c01745
提交
29c01745
authored
8月 27, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
got rid of UncomputableOp (no longer necessary)
上级
bf036c87
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
53 行删除
+0
-53
op.py
theano/gof/op.py
+0
-53
没有找到文件。
theano/gof/op.py
浏览文件 @
29c01745
...
@@ -609,59 +609,6 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -609,59 +609,6 @@ class Op(utils.object2, PureOp, CLinkerOp):
rval
.
lazy
=
False
rval
.
lazy
=
False
return
rval
return
rval
class
UncomputableOp
(
Op
):
"""
An Op representing an expression that cannot be computed.
theano.function checks that the subgraph it implements
does not contain these ops, and that optimization does not
introduce any such ops.
theano.tensor.grad checks the graphs it returns to ensure
they do not contain these ops.
"""
def
__init__
(
self
,
exc
,
msg
=
""
):
"""
exc: the exception type to raise if a subgraph contains
this op.
msg: the message to include in the exception.
"""
self
.
exc
=
exc
self
.
msg
=
msg
def
__eq__
(
self
,
other
):
return
type
(
self
)
==
type
(
other
)
def
__hash__
(
self
):
return
hash
((
type
(
self
)))
def
__str__
(
self
):
return
"Uncomputable{
%
s,
%
s}"
%
(
self
.
exc
,
self
.
msg
)
def
make_node
(
self
,
x
):
if
x
is
None
:
x
=
graph
.
Constant
(
theano
.
gof
.
type
.
generic
,
None
)
return
graph
.
Apply
(
self
,
[
x
],
[
x
.
type
()]
)
def
perform
(
self
,
node
,
inputs
,
out_storage
):
""" This should never be called"""
raise
AssertionError
(
"A BadGradOp should never be compiled, "
+
\
"and certainly not executed."
)
#Note: essentially, this op should just be NaNs_like(inputs[0])
#but 0 * BadGradOp(x) + y optimizes to just y
#so until we develop a way of symbolically representing a variable
#that is always NaN and implement the logic for 0 * NaN = NaN, etc.
#the only way we can guarantee correctness of a theano function
#is to guarantee that its initial subgraph contained no BadGradOps
def
raise_exc
(
self
):
raise
self
.
exc
(
self
.
msg
)
def
raise_if_uncomputable
(
node
):
if
node
is
not
None
:
if
isinstance
(
node
.
op
,
UncomputableOp
):
node
.
op
.
raise_exc
()
def
get_test_value
(
v
):
def
get_test_value
(
v
):
"""
"""
Extract test value from `v`. Raises AttributeError if there is none.
Extract test value from `v`. Raises AttributeError if there is none.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论