提交 e18ea232 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

merge

"""Driver for gradient calculations.""" """Driver for gradient calculations."""
__authors__ = "James Bergstra" __authors__ = "James Bergstra, Ian Goodfellow"
__copyright__ = "(c) 2011, Universite de Montreal" __copyright__ = "(c) 2011, Universite de Montreal"
__license__ = "3-clause BSD License" __license__ = "3-clause BSD License"
__contact__ = "theano-dev <theano-dev@googlegroups.com>" __contact__ = "theano-dev <theano-dev@googlegroups.com>"
...@@ -123,6 +123,8 @@ def grad_sources_inputs(sources, graph_inputs, warn_type=True): ...@@ -123,6 +123,8 @@ def grad_sources_inputs(sources, graph_inputs, warn_type=True):
def unimplemented_grad(op, x_pos, x): def unimplemented_grad(op, x_pos, x):
""" """
DO NOT USE. Remove this function after all usage of it has been removed from theano.
Return an un-computable symbolic variable of type `x.type`. Return an un-computable symbolic variable of type `x.type`.
If any function tries to compute this un-computable variable, an exception If any function tries to compute this un-computable variable, an exception
...@@ -130,5 +132,14 @@ def unimplemented_grad(op, x_pos, x): ...@@ -130,5 +132,14 @@ def unimplemented_grad(op, x_pos, x):
`x_pos`'th input of `op` has not been implemented. `x_pos`'th input of `op` has not been implemented.
""" """
raise Exception("""
unimplemented_grad is not a safe function to use.
It depends on catching errors at the run-time of a theano function.
However, it could be removed by the optimization during the compilation
of the theano function, for example, if it is multiplied by 0. This
results in theano functions returning 0 for gradients that are actually
undefined. """)
msg = '%s.grad not implemented for input %i'%(op, x_pos) msg = '%s.grad not implemented for input %i'%(op, x_pos)
return Raise(msg=msg)(x) return Raise(msg=msg)(x)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论