示例#1
0
import numpy as np
import hmc
params = hmc.HMCParams(
    tau=0.1,
    tau_g=0.4,
    L=10,
    eta=0.0005,
    mass=1,
    r_clip=2,
    grad_clip=1.0,
)
示例#2
0
import hmc

np.random.seed(46327)

problem = circle.problem()
n, data_dim = problem.data.shape
dim = 2

epsilon = 1
delta = 0.1 / n

params = hmc.HMCParams(
    tau=0.6,
    tau_g=1.9,
    L=4 * 12,
    eta=0.07,
    mass=np.array((1, 1)),
    r_clip=0.001,
    grad_clip=0.0015,
)

res = hmc.hmc(problem, np.array((0, 1)), epsilon, delta, params)

samples = res.chain
n_samples = samples.shape[0]
proposals = res.leapfrog_chain
props_per_sample = int(proposals.shape[0] / (samples.shape[0] - 1))
points = np.zeros((props_per_sample + 1, samples.shape[0], dim))
for i in range(samples.shape[0]):
    points[0, i, :] = samples[i, :]
    if i < samples.shape[0] - 1:
import numpy as np
import hmc

params = hmc.HMCParams(
    tau=0.05,
    tau_g=0.20,
    L=5,
    eta=0.00004,
    mass=1,
    r_clip=20,
    grad_clip=25.0,
)
示例#4
0
import numpy as np
import hmc
params = hmc.HMCParams(
    tau=0.08,
    tau_g=0.20,
    L=10,
    eta=0.015,
    mass=1,
    r_clip=2.5,
    grad_clip=3.5,
)
示例#5
0
import numpy as np
import hmc
params = hmc.HMCParams(
    tau=0.2,
    tau_g=0.6,
    L=10,
    eta=0.01,
    mass=1,
    r_clip=2.5,
    grad_clip=2.0,
)
示例#6
0
import numpy as np
import hmc
params = hmc.HMCParams(
    tau = 0.05,
    tau_g = 0.2,
    L = 10,
    eta = 0.00015,
    mass = 1,
    r_clip = 2.5,
    grad_clip = 3.0,
)
示例#7
0
import numpy as np
import hmc
params = hmc.HMCParams(
    tau = 0.05,
    tau_g = 0.10,
    L = 5,
    eta = 0.00025,
    mass = 1,#np.hstack((np.array((0.1, 1)), np.repeat(2, 28))),
    r_clip = 2.5,
    grad_clip = 6.0,
    # tau = 0.05,
    # tau_g = 0.10,
    # L = 5,
    # eta = 0.0002,
    # mass = np.hstack((np.array((0.1, 1)), np.repeat(2, 28))),
    # r_clip = 3.1,
    # grad_clip = 6.0,
)
示例#8
0
import numpy as np
import hmc
params = hmc.HMCParams(
    tau = 0.15,
    tau_g = 0.25,
    L = 5,
    eta = 0.00045,
    mass = 1,
    r_clip = 5.0,
    grad_clip = 2.8,
)
示例#9
0
import numpy as np
import hmc

params = hmc.HMCParams(
    tau=0.05,
    tau_g=0.20,
    L=8,
    eta=0.00007,
    mass=1,
    r_clip=30,
    grad_clip=29.0,
)
示例#10
0
n, data_dim = problem.data.shape
posterior = problem.true_posterior

epsilon = 4
delta = 0.1 / n
start_point = 2

params = hmc.HMCParams(
    tau=0.15,
    tau_g=0.25,
    L=5,
    eta=0.00045,
    mass=1,
    r_clip=4.0,
    grad_clip=2.8,

    # tau = 0.05,
    # tau_g = 0.20,
    # L = 8,
    # eta = 0.00007,
    # mass = 1,#np.hstack((np.array((0.1, 1)), np.repeat(2, 28))),
    # r_clip = 30,
    # grad_clip = 29.0,
)

result = hmc.hmc(problem, problem.get_start_point(start_point), epsilon, delta,
                 params)
final_chain = result.final_chain

print("Acceptance: {}".format(result.acceptance))
print("Clipping: {}".format(result.clipped_r))