Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ColCarroll committed Jul 10, 2017
1 parent 11869f8 commit 1756260
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pymc3/step_methods/hmc/base_hmc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np

from ..arraystep import ArrayStepShared
from .trajectory import get_theano_hamiltonian_functions

from pymc3.tuning import guess_scaling
from pymc3.model import modelcontext, Point
from .quadpotential import quad_potential
from pymc3.theanof import inputvars, make_shared_replacements, floatX
import numpy as np


class BaseHMC(ArrayStepShared):
Expand Down
6 changes: 3 additions & 3 deletions pymc3/step_methods/hmc/hmc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import numpy as np

from ..arraystep import metrop_select, Competence
from .base_hmc import BaseHMC
from pymc3.vartypes import discrete_types
from pymc3.theanof import floatX

import numpy as np


__all__ = ['HamiltonianMC']

Expand All @@ -20,7 +20,7 @@ def unif(step_size, elow=.85, ehigh=1.15):
class HamiltonianMC(BaseHMC):
R"""A sampler for continuous variables based on Hamiltonian mechanics.
See NUTS sampler for automatically tuned stopping time.
See NUTS sampler for automatically tuned stopping time and step size scaling.
"""

name = 'hmc'
Expand Down
12 changes: 6 additions & 6 deletions pymc3/step_methods/hmc/nuts.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from collections import namedtuple
import warnings

import numpy as np
import numpy.random as nr
from scipy import stats, linalg
import six

from ..arraystep import Competence
from pymc3.exceptions import SamplingError
from .base_hmc import BaseHMC
from pymc3.theanof import floatX
from pymc3.vartypes import continuous_types

import numpy as np
import numpy.random as nr
from scipy import stats, linalg
import six

__all__ = ['NUTS']


Expand All @@ -28,7 +28,7 @@ class NUTS(BaseHMC):
sample. A detailed description can be found at [1], "Algorithm 6:
Efficient No-U-Turn Sampler with Dual Averaging".
Nuts provides a number of statistics that can be accessed with
NUTS provides a number of statistics that can be accessed with
`trace.get_sampler_stats`:
- `mean_tree_accept`: The mean acceptance probability for the tree
Expand Down
5 changes: 2 additions & 3 deletions pymc3/step_methods/hmc/quadpotential.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from numpy import dot
import numpy as np
from numpy.random import normal
import scipy.linalg
import theano.tensor as tt
Expand All @@ -7,7 +7,6 @@

from pymc3.theanof import floatX

import numpy as np

__all__ = ['quad_potential', 'ElemWiseQuadPotential', 'QuadPotential',
'QuadPotential_Inv', 'isquadpotential']
Expand Down Expand Up @@ -137,7 +136,7 @@ def velocity(self, x):
def random(self):
"""Draw random value from QuadPotential."""
n = floatX(normal(size=self.L.shape[0]))
return dot(self.L, n)
return np.dot(self.L, n)

def energy(self, x):
"""Compute kinetic energy at a position in parameter space."""
Expand Down
3 changes: 1 addition & 2 deletions pymc3/step_methods/hmc/trajectory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from collections import namedtuple

from pymc3.theanof import join_nonshared_inputs, gradient, CallableTensor, floatX

import theano
import theano.tensor as tt
import numpy as np

from pymc3.theanof import join_nonshared_inputs, gradient, CallableTensor, floatX

Hamiltonian = namedtuple("Hamiltonian", "logp, dlogp, pot")

Expand Down

0 comments on commit 1756260

Please sign in to comment.