提交 b318b860 authored 作者: abalkin's avatar abalkin

Avoid importing theano into itself.

上级 8db8c39d
...@@ -148,9 +148,6 @@ def dot(l, r): ...@@ -148,9 +148,6 @@ def dot(l, r):
(e0, e1)) (e0, e1))
return rval return rval
# Used by get_scalar_constant_value() below. Can be eliminated by looking into globals().
import theano
def get_scalar_constant_value(v): def get_scalar_constant_value(v):
"""return the constant scalar(0-D) value underlying variable `v` """return the constant scalar(0-D) value underlying variable `v`
...@@ -163,10 +160,9 @@ def get_scalar_constant_value(v): ...@@ -163,10 +160,9 @@ def get_scalar_constant_value(v):
If `v` is not some view of constant data, then raise a If `v` is not some view of constant data, then raise a
tensor.basic.NotScalarConstantError. tensor.basic.NotScalarConstantError.
""" """
if hasattr(theano, 'sparse') and isinstance(v.type, # Is it necessary to test for presence of theano.sparse at runtime?
theano.sparse.SparseType): if 'sparse' in globals() and isinstance(v.type, sparse.SparseType):
if v.owner is not None and isinstance(v.owner.op, if v.owner is not None and isinstance(v.owner.op, sparse.CSM):
theano.sparse.CSM):
data = v.owner.inputs[0] data = v.owner.inputs[0]
return tensor.get_scalar_constant_value(data) return tensor.get_scalar_constant_value(data)
return tensor.get_scalar_constant_value(v) return tensor.get_scalar_constant_value(v)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论