提交 7ca064a9 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

added check that cost is a scalar

上级 fa453ec6
......@@ -451,6 +451,9 @@ def grad(cost, wrt, g_cost = None, consider_constant = None, warn_type = 'ignore
if tensor is None:
from theano import tensor
if cost.ndim != 0:
raise TypeError("cost must be a scalar.")
if isinstance(cost.type, NaNType):
raise ValueError("Can't differentiate a NaN cost. cost is NaN because "+\
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论