示例#1
0
rlst_w = np.zeros(x.shape[0])
rlst_w[rlst_idcs] = 2. * x.shape[0] / rlst_idcs.shape[0] * np.random.rand(
    rlst_idcs.shape[0])
tsf_exact_realistic = lambda: tsf_exact_w(2. * np.random.rand(x.shape[0]),
                                          np.arange(x.shape[0]))

##############################

# create coreset construction objects
sparsevi = bc.SparseVICoreset(tsf_exact_w, opt_itrs)
giga_optimal = bc.HilbertCoreset(tsf_optimal)
giga_optimal_exact = bc.HilbertCoreset(tsf_exact_optimal)
giga_realistic = bc.HilbertCoreset(tsf_realistic)
giga_realistic_exact = bc.HilbertCoreset(tsf_exact_realistic)
unif = bc.UniformSamplingCoreset(x.shape[0])
iht = bc.IHTCoreset(tsf_exact_optimal, proj_dim, 'IHT')
iht_2 = bc.IHTCoreset(tsf_exact_optimal, proj_dim, 'IHT-2')

algs = {
    'SVI': sparsevi,
    'GIGAO': giga_optimal,
    'GIGAOE': giga_optimal_exact,
    'GIGAR': giga_realistic,
    'GIGARE': giga_realistic_exact,
    'RAND': unif,
    'IHT': iht,
    'IHT-2': iht_2
}
alg = algs[nm]

w = np.zeros((M + 1, x.shape[0]))
        muw, Sigw = mu0, Sig0
    return np.random.multivariate_normal(muw, Sigw, sz)


tsf_w = bc.BayesianTangentSpaceFactory(lambda th: log_likelihood_2d2d(Z, th),
                                       sampler_w, projection_dim)

print('Creating coresets object')
# create coreset construction objects
giga_optimal = bc.HilbertCoreset(tsf_optimal)
giga_realistic = bc.HilbertCoreset(tsf_realistic)
unif = bc.UniformSamplingCoreset(Z.shape[0])
sparsevi = bc.SparseVICoreset(tsf_w,
                              opt_itrs=opt_itrs,
                              step_sched=learning_rate)
iht = bc.IHTCoreset(tsf_realistic, projection_dim, 'IHT')
iht_ii = bc.IHTCoreset(tsf_realistic, projection_dim, 'IHT-2')

algs = {
    'SVI': sparsevi,
    'GIGAO': giga_optimal,
    'GIGAR': giga_realistic,
    'RAND': unif,
    'IHT': iht,
    'IHT-2': iht_ii,
    'PRIOR': None
}
coreset = algs[alg]

print('Building coresets via ' + alg)
# build
示例#3
0
        w[idcs] = wts
        muw, Sigw = get_laplace(w, Z, mu0)
    else:
        muw, Sigw = mu0, Sig0
    return np.random.multivariate_normal(muw, Sigw, sz)


tsf_w = bc.BayesianTangentSpaceFactory(lambda th: log_likelihood_2d2d(Z, th), sampler_w, projection_dim)

print('Creating coresets object')
# create coreset construction objects
giga_optimal = bc.HilbertCoreset(tsf_optimal)
giga_realistic = bc.HilbertCoreset(tsf_realistic)
unif = bc.UniformSamplingCoreset(Z.shape[0])
sparsevi = bc.SparseVICoreset(tsf_w, opt_itrs=opt_itrs, step_sched=learning_rate)
iht = bc.IHTCoreset(tsf_realistic, projection_dim, 'IHT')
iht_ii = bc.IHTCoreset(tsf_realistic, projection_dim, 'IHT-2')
iht_stoc = bc.IHTCoreset(tsf_realistic, projection_dim, 'IHT', stochastic_batch_ratio=stochastic_batch_ratio)
algs = {'SVI': sparsevi,
        'GIGAO': giga_optimal,
        'GIGAR': giga_realistic,
        'RAND': unif,
        'IHT': iht,
        'IHT-2': iht_ii,
        'IHT-stoc': iht_stoc,
        'PRIOR': None}

coreset = algs[alg]

print('Building coresets via ' + alg)
# build