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

added type-checking enforcing that gradients are not integers

上级 f02b01d4
......@@ -776,6 +776,17 @@ def _populate_grad_dict(var_to_node_to_idx,
' a gradient term, '
'this is prohibited') % node.op)
if not isinstance(term.type,
(NullType,DisconnectedType)):
assert hasattr(term,'dtype')
if term.dtype.find('float') == -1:
raise TypeError(str(node.op)+'.grad illegally '
' returned an integer-valued variable.'
' (Input index %d, dtype %s' % (i,
term.dtype))
#cache the result
term_dict[node] = input_grads
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论