提交 76a22232 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

doc of what to return instead of None

上级 748116e8
...@@ -771,9 +771,13 @@ def _populate_grad_dict(var_to_node_to_idx, ...@@ -771,9 +771,13 @@ def _populate_grad_dict(var_to_node_to_idx,
# used to mean undefined, zero, or disconnected. # used to mean undefined, zero, or disconnected.
# We therefore don't allow it because its usage has become # We therefore don't allow it because its usage has become
# so muddied. # so muddied.
raise TypeError(('%s returned None for' +\ raise TypeError(('%s.grad returned None for' +\
' a gradient term, ' ' a gradient term, '
'this is prohibited') % node.op) 'this is prohibited. Instead of None,'
'return zeros_like(input), DisconnectedType()(),'
' or a NullType variable such as those made with '
'the grad_undefined or grad_unimplemented helper '
'functions.') % node.op)
if not isinstance(term.type, if not isinstance(term.type,
(NullType,DisconnectedType)): (NullType,DisconnectedType)):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论