@@ -196,12 +196,13 @@ def Rop(
196
196
197
197
Returns
198
198
-------
199
+ :class:`~pytensor.graph.basic.Variable` or list/tuple of Variables
199
200
A symbolic expression such obeying
200
201
``R_op[i] = sum_j (d f[i] / d wrt[j]) eval_point[j]``,
201
202
where the indices in that expression are magic multidimensional
202
203
indices that specify both the position within a list and all
203
204
coordinates of the tensor elements.
204
- If `wrt ` is a list/tuple, then return a list/tuple with the results.
205
+ If `f ` is a list/tuple, then return a list/tuple with the results.
205
206
"""
206
207
207
208
if not isinstance (wrt , (list , tuple )):
@@ -384,6 +385,7 @@ def Lop(
384
385
385
386
Returns
386
387
-------
388
+ :class:`~pytensor.graph.basic.Variable` or list/tuple of Variables
387
389
A symbolic expression satisfying
388
390
``L_op[i] = sum_i (d f[i] / d wrt[j]) eval_point[i]``
389
391
where the indices in that expression are magic multidimensional
@@ -481,10 +483,10 @@ def grad(
481
483
482
484
Returns
483
485
-------
486
+ :class:`~pytensor.graph.basic.Variable` or list/tuple of Variables
484
487
A symbolic expression for the gradient of `cost` with respect to each
485
488
of the `wrt` terms. If an element of `wrt` is not differentiable with
486
489
respect to the output, then a zero variable is returned.
487
-
488
490
"""
489
491
t0 = time .perf_counter ()
490
492
@@ -701,7 +703,6 @@ def subgraph_grad(wrt, end, start=None, cost=None, details=False):
701
703
702
704
Parameters
703
705
----------
704
-
705
706
wrt : list of variables
706
707
Gradients are computed with respect to `wrt`.
707
708
@@ -876,7 +877,6 @@ def _populate_var_to_app_to_idx(outputs, wrt, consider_constant):
876
877
877
878
(A variable in consider_constant is not a function of
878
879
anything)
879
-
880
880
"""
881
881
882
882
# Validate and format consider_constant
@@ -1035,7 +1035,6 @@ def _populate_grad_dict(var_to_app_to_idx, grad_dict, wrt, cost_name=None):
1035
1035
-------
1036
1036
list of Variables
1037
1037
A list of gradients corresponding to `wrt`
1038
-
1039
1038
"""
1040
1039
# build a dict mapping node to the terms node contributes to each of
1041
1040
# its inputs' gradients
@@ -1423,8 +1422,9 @@ def access_grad_cache(var):
1423
1422
1424
1423
1425
1424
def _float_zeros_like (x ):
1426
- """Like zeros_like, but forces the object to have a
1427
- a floating point dtype"""
1425
+ """Like zeros_like, but forces the object to have
1426
+ a floating point dtype
1427
+ """
1428
1428
1429
1429
rval = x .zeros_like ()
1430
1430
@@ -1436,7 +1436,8 @@ def _float_zeros_like(x):
1436
1436
1437
1437
def _float_ones_like (x ):
1438
1438
"""Like ones_like, but forces the object to have a
1439
- floating point dtype"""
1439
+ floating point dtype
1440
+ """
1440
1441
1441
1442
dtype = x .type .dtype
1442
1443
if dtype not in pytensor .tensor .type .float_dtypes :
@@ -1613,7 +1614,6 @@ def abs_rel_errors(self, g_pt):
1613
1614
1614
1615
Corresponding ndarrays in `g_pt` and `self.gf` must have the same
1615
1616
shape or ValueError is raised.
1616
-
1617
1617
"""
1618
1618
if len (g_pt ) != len (self .gf ):
1619
1619
raise ValueError ("argument has wrong number of elements" , len (g_pt ))
@@ -1740,7 +1740,6 @@ def verify_grad(
1740
1740
This function does not support multiple outputs. In `tests.scan.test_basic`
1741
1741
there is an experimental `verify_grad` that covers that case as well by
1742
1742
using random projections.
1743
-
1744
1743
"""
1745
1744
from pytensor .compile .function import function
1746
1745
from pytensor .compile .sharedvalue import shared
@@ -2267,7 +2266,6 @@ def grad_clip(x, lower_bound, upper_bound):
2267
2266
-----
2268
2267
We register an opt in tensor/opt.py that remove the GradClip.
2269
2268
So it have 0 cost in the forward and only do work in the grad.
2270
-
2271
2269
"""
2272
2270
return GradClip (lower_bound , upper_bound )(x )
2273
2271
0 commit comments