Exemplo n.º 1
0
 def __init__(self, target, momentum, num_steps_min=10, num_steps_max=100, step_size_min=0.05,
              step_size_max=0.3, adaptation_schedule=standard_sqrt_schedule, acc_star=0.7):
     
     if not isinstance(momentum, GaussianBase):
         raise TypeError("Momentum (%s) must be subclass of %s" % \
                         (str(type(momentum)), str(GaussianBase)))
     assert_implements_log_pdf_and_grad(target)
     assert_implements_log_pdf_and_grad(momentum)
     assert_inout_log_pdf_and_grad(target, momentum.D, assert_grad=False)
         
     assert_positive_int(num_steps_min)
     assert_positive_int(num_steps_max)
     if not num_steps_min<=num_steps_max:
         raise ValueError("Minimum number of leapfrog steps (%d) must be larger than maximum number (%d)." % \
                          (num_steps_min, num_steps_max))
     
     assert_positive_float(step_size_min)
     assert_positive_float(step_size_max)
     if not num_steps_min<=num_steps_max:
         raise ValueError("Minimum size of leapfrog steps (%d) must be larger than maximum size (%d)." % \
                          (step_size_min, step_size_max))
     
     step_size = np.array([step_size_min, step_size_max])
     ProposalBase.__init__(self, target, momentum.D, step_size, adaptation_schedule, acc_star)
     
     self.momentum = momentum
     self.num_steps_min = num_steps_min
     self.num_steps_max = num_steps_max
Exemplo n.º 2
0
 def __init__(self, target, D, N, kernel_sigma=1., minimum_size_sigma_learning=100,
              step_size=1., gamma2=0.1, adaptation_schedule=standard_sqrt_schedule, acc_star=0.234):
     ProposalBase.__init__(self, target, D, step_size, adaptation_schedule, acc_star)
     
     self.kernel_sigma = kernel_sigma
     self.minimum_size_sigma_learning = minimum_size_sigma_learning
     self.N = N
     self.gamma2 = gamma2
     self.Z = np.zeros((0, D))
Exemplo n.º 3
0
 def __init__(self, target, D, step_size=1., gamma2=0.1,
              adaptation_schedule=standard_sqrt_schedule, acc_star=0.234):
     ProposalBase.__init__(self, target, D, step_size, adaptation_schedule, acc_star)
     
     self.gamma2 = gamma2
     
     # initialise as scaled isotropic, otherwise Cholesky updates fail
     self.mu = np.zeros(self.D)
     self.L_C = np.eye(self.D) * np.sqrt(self.step_size)    
Exemplo n.º 4
0
    def __init__(self,
                 target,
                 momentum,
                 num_steps_min=10,
                 num_steps_max=100,
                 step_size_min=0.05,
                 step_size_max=0.3,
                 adaptation_schedule=standard_sqrt_schedule,
                 acc_star=0.7):

        if not isinstance(momentum, GaussianBase):
            raise TypeError("Momentum (%s) must be subclass of %s" % \
                            (str(type(momentum)), str(GaussianBase)))
        assert_implements_log_pdf_and_grad(target)
        assert_implements_log_pdf_and_grad(momentum)
        assert_inout_log_pdf_and_grad(target, momentum.D, assert_grad=False)

        assert_positive_int(num_steps_min)
        assert_positive_int(num_steps_max)
        if not num_steps_min <= num_steps_max:
            raise ValueError("Minimum number of leapfrog steps (%d) must be larger than maximum number (%d)." % \
                             (num_steps_min, num_steps_max))

        assert_positive_float(step_size_min)
        assert_positive_float(step_size_max)
        if not num_steps_min <= num_steps_max:
            raise ValueError("Minimum size of leapfrog steps (%d) must be larger than maximum size (%d)." % \
                             (step_size_min, step_size_max))

        step_size = np.array([step_size_min, step_size_max])
        ProposalBase.__init__(self, target, momentum.D, step_size,
                              adaptation_schedule, acc_star)

        self.momentum = momentum
        self.num_steps_min = num_steps_min
        self.num_steps_max = num_steps_max