提交 f30f649f authored 作者: Olivier Delalleau's avatar Olivier Delalleau

More helpful error message

上级 fe312cee
...@@ -462,13 +462,16 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None, ...@@ -462,13 +462,16 @@ def pfunc(params, outputs=None, mode=None, updates=None, givens=None,
for x, y in givens_pairs: for x, y in givens_pairs:
if x in in_var_set: if x in in_var_set:
raise RuntimeError( raise RuntimeError(
'You cannot replace variable \'%s\' (found in the ' 'You are trying to replace variable \'%s\' through the '
'`givens` argument), because it is an input to the ' '`givens` parameter, but this variable is an input to your '
'function. If your goal is to replace some input ' 'function. Replacing inputs is currently forbidden because it '
'x to your output f(x) by an expression g(y), so as to ' 'has no effect. One way to modify an input `x` to a function '
'compute f(g(y)), then you can achieve this by defining ' 'evaluating f(x) is to define a new input `y` and use '
'a new variable y and compiling your function ' '`theano.function([y], f(x), givens={x: g(y)})`. Another '
'as: function([y], f(x), givens={x: g(y)}).' % x) 'solution consists in using `theano.clone`, e.g. like this: '
'`theano.function([x], '
'theano.clone(f(x), replace={x: g(x)}))`.'
% x)
output_vars = rebuild_collect_shared(outputs, output_vars = rebuild_collect_shared(outputs,
in_variables, in_variables,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论