Пример #1
0
]
optimizers = [
    SgdOptimizer(1),
    SgdOptimizer(0.1),
    SgdOptimizer(0.05),
    AdamOptimizer(len(psi.parameters), 0.1, 0.9),
    AdamOptimizer(len(psi.parameters), 0.1, 0.8),
]
E = []
for opt in optimizers:
    # psi.parameters = org_params
    psi = RBMWavefunction(N * D, 2)
    # psi = SimpleGaussian(0.8)
    sampler = ImportanceSampler(system, psi, 0.1)
    sampler.thermalize(10000)
    E_training = EnergyCallback(samples=1000000, verbose=True)
    train(
        psi,
        H,
        sampler,
        iters=500,
        samples=1000,
        gamma=0.0,
        optimizer=opt,
        call_backs=[E_training],
        call_back_resolution=50,
    )
    E.append(np.asarray(E_training))

if master_rank():
    fig, ax = plt.subplots()