Skip to content

Commit 0ba554b

Browse files
t3chwMohit Kumar
and
Mohit Kumar
authored
Do not require RNG in 'verify_grad' (#1093)
Co-authored-by: Mohit Kumar <[email protected]>
1 parent bad8d20 commit 0ba554b

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

pytensor/gradient.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1770,14 +1770,9 @@ def verify_grad(
17701770
if rel_tol is None:
17711771
rel_tol = max(_type_tol[str(p.dtype)] for p in pt)
17721772

1773+
# Initialize RNG if not provided
17731774
if rng is None:
1774-
raise TypeError(
1775-
"rng should be a valid instance of "
1776-
"numpy.random.RandomState. You may "
1777-
"want to use tests.unittest"
1778-
"_tools.verify_grad instead of "
1779-
"pytensor.gradient.verify_grad."
1780-
)
1775+
rng = np.random.default_rng()
17811776

17821777
# We allow input downcast in `function`, because `numeric_grad` works in
17831778
# the most precise dtype used among the inputs, so we may need to cast

0 commit comments

Comments
 (0)