@@ -398,10 +398,10 @@ class Model(WithMemoization, metaclass=ContextMeta):
398
398
399
399
Parameters
400
400
----------
401
- name: str
401
+ name : str
402
402
name that will be used as prefix for names of all random
403
403
variables defined within model
404
- check_bounds: bool
404
+ check_bounds : bool
405
405
Ensure that input parameters to distributions are in a valid
406
406
range. If your model is built in a way where you know your
407
407
parameters can only take on valid values you can set this to
@@ -580,10 +580,10 @@ def logp_dlogp_function(self, grad_vars=None, tempered=False, **kwargs):
580
580
581
581
Parameters
582
582
----------
583
- grad_vars: list of random variables, optional
583
+ grad_vars : list of random variables, optional
584
584
Compute the gradient with respect to those variables. If None,
585
585
use all free random variables of this model.
586
- tempered: bool
586
+ tempered : bool
587
587
Compute the tempered logp `free_logp + alpha * observed_logp`.
588
588
`alpha` can be changed using `ValueGradFunction.set_weights([alpha])`.
589
589
"""
@@ -619,12 +619,12 @@ def compile_logp(
619
619
620
620
Parameters
621
621
----------
622
- vars: list of random variables or potential terms, optional
622
+ vars : list of random variables or potential terms, optional
623
623
Compute the gradient with respect to those variables. If None, use all
624
624
free and observed random variables, as well as potential terms in model.
625
- jacobian:
625
+ jacobian : bool
626
626
Whether to include jacobian terms in logprob graph. Defaults to True.
627
- sum:
627
+ sum : bool
628
628
Whether to sum all logp terms or return elemwise logp for each variable.
629
629
Defaults to True.
630
630
"""
@@ -639,10 +639,10 @@ def compile_dlogp(
639
639
640
640
Parameters
641
641
----------
642
- vars: list of random variables or potential terms, optional
642
+ vars : list of random variables or potential terms, optional
643
643
Compute the gradient with respect to those variables. If None, use all
644
644
free and observed random variables, as well as potential terms in model.
645
- jacobian:
645
+ jacobian : bool
646
646
Whether to include jacobian terms in logprob graph. Defaults to True.
647
647
"""
648
648
return self .compile_fn (self .dlogp (vars = vars , jacobian = jacobian ))
@@ -656,10 +656,10 @@ def compile_d2logp(
656
656
657
657
Parameters
658
658
----------
659
- vars: list of random variables or potential terms, optional
659
+ vars : list of random variables or potential terms, optional
660
660
Compute the gradient with respect to those variables. If None, use all
661
661
free and observed random variables, as well as potential terms in model.
662
- jacobian:
662
+ jacobian : bool
663
663
Whether to include jacobian terms in logprob graph. Defaults to True.
664
664
"""
665
665
return self .compile_fn (self .d2logp (vars = vars , jacobian = jacobian ))
@@ -674,12 +674,12 @@ def logp(
674
674
675
675
Parameters
676
676
----------
677
- vars: list of random variables or potential terms, optional
677
+ vars : list of random variables or potential terms, optional
678
678
Compute the gradient with respect to those variables. If None, use all
679
679
free and observed random variables, as well as potential terms in model.
680
- jacobian:
680
+ jacobian : bool
681
681
Whether to include jacobian terms in logprob graph. Defaults to True.
682
- sum:
682
+ sum : bool
683
683
Whether to sum all logp terms or return elemwise logp for each variable.
684
684
Defaults to True.
685
685
@@ -752,10 +752,10 @@ def dlogp(
752
752
753
753
Parameters
754
754
----------
755
- vars: list of random variables or potential terms, optional
755
+ vars : list of random variables or potential terms, optional
756
756
Compute the gradient with respect to those variables. If None, use all
757
757
free and observed random variables, as well as potential terms in model.
758
- jacobian:
758
+ jacobian : bool
759
759
Whether to include jacobian terms in logprob graph. Defaults to True.
760
760
761
761
Returns
@@ -791,10 +791,10 @@ def d2logp(
791
791
792
792
Parameters
793
793
----------
794
- vars: list of random variables or potential terms, optional
794
+ vars : list of random variables or potential terms, optional
795
795
Compute the gradient with respect to those variables. If None, use all
796
796
free and observed random variables, as well as potential terms in model.
797
- jacobian:
797
+ jacobian : bool
798
798
Whether to include jacobian terms in logprob graph. Defaults to True.
799
799
800
800
Returns
@@ -961,7 +961,7 @@ def add_coord(
961
961
name : str
962
962
Name of the dimension.
963
963
Forbidden: {"chain", "draw", "__sample__"}
964
- values : optional, array-like
964
+ values : optional, array_like
965
965
Coordinate values or ``None`` (for auto-numbering).
966
966
If ``None`` is passed, a ``length`` must be specified.
967
967
mutable : bool
@@ -1021,11 +1021,11 @@ def set_dim(self, name: str, new_length: int, coord_values: Optional[Sequence] =
1021
1021
1022
1022
Parameters
1023
1023
----------
1024
- name
1024
+ name : str
1025
1025
Name of the dimension.
1026
- new_length
1026
+ new_length : int
1027
1027
New length of the dimension.
1028
- coord_values
1028
+ coord_values : array_like, optional
1029
1029
Optional sequence of coordinate values.
1030
1030
"""
1031
1031
if not isinstance (self .dim_lengths [name ], SharedVariable ):
@@ -1085,7 +1085,7 @@ def set_data(
1085
1085
----------
1086
1086
name : str
1087
1087
Name of a shared variable in the model.
1088
- values : array-like
1088
+ values : array_like
1089
1089
New values for the shared variable.
1090
1090
coords : optional, dict
1091
1091
New coordinate values for dimensions of the shared variable.
@@ -1213,14 +1213,14 @@ def register_rv(
1213
1213
1214
1214
Parameters
1215
1215
----------
1216
- rv_var: TensorVariable
1217
- name: str
1216
+ rv_var : TensorVariable
1217
+ name : str
1218
1218
Intended name for the model variable.
1219
- observed: array_like ( optional)
1219
+ observed : array_like, optional
1220
1220
Data values for observed variables.
1221
- total_size: scalar
1221
+ total_size : scalar
1222
1222
upscales logp of variable with ``coef = total_size/var.shape[0]``
1223
- dims: tuple
1223
+ dims : tuple
1224
1224
Dimension names for the variable.
1225
1225
transform
1226
1226
A transform for the random variable in log-likelihood space.
@@ -1287,16 +1287,19 @@ def make_obs_var(
1287
1287
1288
1288
Parameters
1289
1289
----------
1290
- rv_var
1290
+ rv_var : TensorVariable
1291
1291
The random variable that is observed.
1292
1292
Its dimensionality must be compatible with the data already.
1293
- data
1293
+ data : array_like
1294
1294
The observed data.
1295
- dims: tuple
1295
+ dims : tuple
1296
1296
Dimension names for the variable.
1297
- transform
1297
+ transform : int, optional
1298
1298
A transform for the random variable in log-likelihood space.
1299
1299
1300
+ Returns
1301
+ -------
1302
+ TensorVariable
1300
1303
"""
1301
1304
name = rv_var .name
1302
1305
data = convert_observed_data (data ).astype (rv_var .dtype )
@@ -1371,6 +1374,17 @@ def create_value_var(
1371
1374
observed data. That's why value variables are only referenced in
1372
1375
this branch of the conditional.
1373
1376
1377
+ Parameters
1378
+ ----------
1379
+ rv_var : TensorVariable
1380
+
1381
+ transform : Any
1382
+
1383
+ value_var : Variable, optional
1384
+
1385
+ Returns
1386
+ -------
1387
+ TensorVariable
1374
1388
"""
1375
1389
1376
1390
# Make the value variable a transformed value variable,
@@ -1414,6 +1428,13 @@ def add_named_variable(self, var, dims: Optional[tuple[Union[str, None], ...]] =
1414
1428
1415
1429
This can include several types of variables such basic_RVs, Data, Deterministics,
1416
1430
and Potentials.
1431
+
1432
+ Parameters
1433
+ ----------
1434
+ var
1435
+
1436
+ dims : tuple, optional
1437
+
1417
1438
"""
1418
1439
if var .name is None :
1419
1440
raise ValueError ("Variable is unnamed." )
@@ -1486,8 +1507,12 @@ def replace_rvs_by_values(
1486
1507
1487
1508
Parameters
1488
1509
----------
1489
- graphs
1510
+ graphs : array_like
1490
1511
The graphs in which to perform the replacements.
1512
+
1513
+ Returns
1514
+ -------
1515
+ array_like
1491
1516
"""
1492
1517
return replace_rvs_by_values (
1493
1518
graphs ,
@@ -1508,9 +1533,9 @@ def compile_fn(
1508
1533
1509
1534
Parameters
1510
1535
----------
1511
- outs
1536
+ outs : Variable or sequence of Variables
1512
1537
PyTensor variable or iterable of PyTensor variables.
1513
- inputs
1538
+ inputs : sequence of Variables, optional
1514
1539
PyTensor input variables, defaults to pytensorf.inputvars(outs).
1515
1540
mode
1516
1541
PyTensor compilation mode, default=None.
@@ -1545,12 +1570,12 @@ def profile(self, outs, *, n=1000, point=None, profile=True, **kwargs):
1545
1570
1546
1571
Parameters
1547
1572
----------
1548
- outs: PyTensor variable or iterable of PyTensor variables
1549
- n: int, default 1000
1573
+ outs : PyTensor variable or iterable of PyTensor variables
1574
+ n : int, default 1000
1550
1575
Number of iterations to run
1551
- point: point
1576
+ point : Point
1552
1577
Point to pass to the function
1553
- profile: True or ProfileStats
1578
+ profile : True or ProfileStats
1554
1579
args, kwargs
1555
1580
Compilation args
1556
1581
@@ -1575,6 +1600,11 @@ def update_start_vals(self, a: dict[str, np.ndarray], b: dict[str, np.ndarray]):
1575
1600
Values specified for transformed variables in `a` will be recomputed
1576
1601
conditional on the values of `b` and stored in `b`.
1577
1602
1603
+ Parameters
1604
+ ----------
1605
+ a : dict
1606
+
1607
+ b : dict
1578
1608
"""
1579
1609
raise FutureWarning (
1580
1610
"The `Model.update_start_vals` method was removed."
@@ -1662,10 +1692,10 @@ def point_logps(self, point=None, round_vals=2):
1662
1692
1663
1693
Parameters
1664
1694
----------
1665
- point: Point, optional
1695
+ point : Point, optional
1666
1696
Point to be evaluated. If ``None``, then ``model.initial_point``
1667
1697
is used.
1668
- round_vals: int, default 2
1698
+ round_vals : int, default 2
1669
1699
Number of decimals to round log-probabilities.
1670
1700
1671
1701
Returns
@@ -1704,7 +1734,7 @@ def debug(
1704
1734
1705
1735
Parameters
1706
1736
----------
1707
- point : Point
1737
+ point : Point, optional
1708
1738
Point at which model function should be evaluated
1709
1739
fn : str, default "logp"
1710
1740
Function to be used for debugging. Can be one of [logp, dlogp, random].
0 commit comments