提交 457285d6 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

added get_test_value

上级 80bc0102
...@@ -545,3 +545,21 @@ class Op(utils.object2, PureOp, CLinkerOp): ...@@ -545,3 +545,21 @@ class Op(utils.object2, PureOp, CLinkerOp):
rval.perform = p rval.perform = p
rval.lazy = False rval.lazy = False
return rval return rval
def get_test_value(v):
"""
Extract test value from variable v. Raises AttributeError if there is none.
For an ndarray, the value is the ndarray itself
For a Constant, the test value is v.value.
For a Shared variable, it is the internal value.
For another Variable, it is the content of v.tag.test_value."""
try:
return PureOp._get_test_value(v)
except AttributeError:
if hasattr(v,'__array__'):
return v
raise
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论