提交 8e99e640 authored 作者: Frederic's avatar Frederic

In an error message, tell witch input index is problematic.

上级 94006b16
...@@ -1102,8 +1102,8 @@ class FunctionMaker(object): ...@@ -1102,8 +1102,8 @@ class FunctionMaker(object):
blockers=[i.variable for i in inputs]) blockers=[i.variable for i in inputs])
msg = ("theano.function was asked to create a function computing " msg = ("theano.function was asked to create a function computing "
"outputs given certain inputs, but one of the provided " "outputs given certain inputs, but the provided input "
"input variables is not part of the computational graph " "variable at index %i is not part of the computational graph "
"needed to compute the outputs: %s.\n%s") "needed to compute the outputs: %s.\n%s")
warn_msg = ("To make this warning into an error, you can pass the " warn_msg = ("To make this warning into an error, you can pass the "
"parameter on_unused_input='raise' to theano.function. " "parameter on_unused_input='raise' to theano.function. "
...@@ -1115,9 +1115,9 @@ class FunctionMaker(object): ...@@ -1115,9 +1115,9 @@ class FunctionMaker(object):
for i in inputs: for i in inputs:
if ((i.variable not in used_inputs) and (i.update is None)): if ((i.variable not in used_inputs) and (i.update is None)):
if on_unused_input == 'warn': if on_unused_input == 'warn':
warnings.warn(msg % (i.variable, warn_msg), stacklevel=6) warnings.warn(msg % (inputs.index(i), i.variable, warn_msg), stacklevel=6)
elif on_unused_input == 'raise': elif on_unused_input == 'raise':
raise UnusedInputError(msg % (i.variable, err_msg)) raise UnusedInputError(msg % (inputs.index(i), i.variable, err_msg))
else: else:
raise ValueError(("Invalid value for keyword " raise ValueError(("Invalid value for keyword "
"on_unused_input of theano.function: '%s'. " "on_unused_input of theano.function: '%s'. "
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论