-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Before
Passing on_unused_input="ignore" to eval when the inputs_to_values dictionary is indexed by the pytensor variables properly ignores any unused inputs since on_unused_input is passed along to pytensor.function. When the dictionary is indexed by strings, however, the helper function convert_string_keys_to_variables will raise a ValueError when a given input name is not found in the graph, regardless of the value of on_unused_input.
After
Both of these eval statements should work, but the latter raises a ValueError.
import pytensor.tensor as pt
x = pt.dscalar("x")
y = pt.dscalar("y")
z = x + 1.0
print(z.eval({x: 1.0, y: 0.0}, on_unused_input="warn"))
print(z.eval({"x": 1.0, "y": 0.0}, on_unused_input="warn"))Context for the issue:
Users may wish to evaluate a pytensor function after having lost references to the underlying pytensor variables, in which case the easiest (or only) solution is to index the inputs_to_values dictionary by the variable names. The user then has to determine which variables are needed to evaluate a given function, which is cumbersome.