@@ -14,15 +14,15 @@ def _theano_hamiltonian(model_vars, shared, logpt, potential):
14
14
15
15
Parameters
16
16
----------
17
- model_vars: array of variables to be sampled
18
- shared theano tensors that are already shared
19
- logpt: model log probability
20
- potential: hamiltonian potential
17
+ model_vars : array of variables to be sampled
18
+ shared : theano tensors that are already shared
19
+ logpt : model log probability
20
+ potential : hamiltonian potential
21
21
22
22
Returns
23
23
-------
24
- Hamiltonian: namedtuple with log pdf, gradient of log pdf, and potential functions
25
- q: Starting position variable.
24
+ Hamiltonian : namedtuple with log pdf, gradient of log pdf, and potential functions
25
+ q : Starting position variable.
26
26
"""
27
27
dlogp = gradient (logpt , model_vars )
28
28
(logp , dlogp ), q = join_nonshared_inputs ([logpt , dlogp ], model_vars , shared )
@@ -36,14 +36,14 @@ def _theano_energy_function(H, q, **theano_kwargs):
36
36
37
37
Parameters
38
38
----------
39
- H: Hamiltonian namedtuple
40
- q: theano variable, starting position
41
- theano_kwargs: passed to theano.function
39
+ H : Hamiltonian namedtuple
40
+ q : theano variable, starting position
41
+ theano_kwargs : passed to theano.function
42
42
43
43
Returns
44
44
-------
45
- energy_function: theano function that computes the energy at a point (p, q) in phase space
46
- p: Starting momentum variable.
45
+ energy_function : theano function that computes the energy at a point (p, q) in phase space
46
+ p : Starting momentum variable.
47
47
"""
48
48
p = tt .dvector ('p' )
49
49
p .tag .test_value = q .tag .test_value
@@ -91,19 +91,19 @@ def get_theano_hamiltonian_functions(model_vars, shared, logpt, potential,
91
91
Parameters
92
92
----------
93
93
model_vars : array of variables to be sampled
94
- shared theano tensors that are already shared
95
- logpt: model log probability
96
- potential: hamiltonian potential
94
+ shared : theano tensors that are already shared
95
+ logpt : model log probability
96
+ potential : Hamiltonian potential
97
97
theano_kwargs : dictionary of keyword arguments to pass to theano functions
98
- use_single_leapfrog: Boolean, if only 1 integration step is done at a time (as in NUTS),
99
- this provides a ~2x speedup
98
+ use_single_leapfrog : Boolean, if only 1 integration step is done at a time (as in NUTS),
99
+ this provides a ~2x speedup
100
100
101
101
Returns
102
102
-------
103
- H: Hamiltonian namedtuple
104
- energy_function: theano function computing energy at a point in phase space
105
- leapfrog_integrator: theano function integrating the Hamiltonian from a point in phase space
106
- theano_variables: dictionary of variables used in the computation graph which may be useful
103
+ H : Hamiltonian namedtuple
104
+ energy_function : theano function computing energy at a point in phase space
105
+ leapfrog_integrator : theano function integrating the Hamiltonian from a point in phase space
106
+ theano_variables : dictionary of variables used in the computation graph which may be useful
107
107
"""
108
108
H , q = _theano_hamiltonian (model_vars , shared , logpt , potential )
109
109
energy_function , p = _theano_energy_function (H , q , ** theano_kwargs )
@@ -137,18 +137,18 @@ def leapfrog(H, q, p, epsilon, n_steps):
137
137
----------
138
138
H : Hamiltonian instance.
139
139
Tuple of `logp, dlogp, potential`.
140
- q: Theano.tensor
140
+ q : Theano.tensor
141
141
initial position vector
142
- p: Theano.tensor
142
+ p : Theano.tensor
143
143
initial momentum vector
144
- epsilon: float, step size
145
- n_steps: int, number of iterations
144
+ epsilon : float, step size
145
+ n_steps : int, number of iterations
146
146
147
147
Returns
148
148
-------
149
- position: Theano.tensor
149
+ position : Theano.tensor
150
150
position estimate at time :math:`n \cdot e`.
151
- momentum: Theano.tensor
151
+ momentum : Theano.tensor
152
152
momentum estimate at time :math:`n \cdot e`.
153
153
"""
154
154
def full_update (p , q ):
0 commit comments