示例#1
0
 def load(cls, filename, clear_session=True):
     """ Loads parameters into model. Careful: this clears the whole TF session!!
     """
     from deep_boltzmann.util import load_obj
     if clear_session:
         keras.backend.clear_session()
     D = load_obj(filename)
     prior = D['prior']
     layerdicts = D['layers']
     layers = [eval(d['type']).from_dict(d) for d in layerdicts]
     return InvNet(D['dim'], layers, prior=prior)
示例#2
0
 def load(cls, filename):
     """ Loads parameters into model. The resulting model is just a data container.
     """
     from deep_boltzmann.util import load_obj
     D = load_obj(filename)
     umbrellas = [UmbrellaModel.from_dict(u) for u in D['umbrellas']]
     us = cls(None,
              None,
              None,
              None,
              len(umbrellas),
              umbrellas[0].k_umbrella,
              umbrellas[0].m_umbrella,
              umbrellas[-1].m_umbrella,
              forward_backward=D['forward_backward'])
     us.umbrellas = umbrellas
     if 'rc_discretization' in D:
         us.rc_discretization = D['rc_discretization']
         us.rc_free_energies = D['rc_free_energies']
     return us
mm_cyc9 = MM(toppar_cyc9, align=0.0)
top_cyc9 = toppar_cyc9.mdtraj_topology()
rotamer_mapper = RotamerMapper(9)

# get C torsions
Ctor = []
for i, tor in enumerate(toppar_cyc9.torsion_indices):
    is_Ctor = True
    for j in tor:
        if not toppar_cyc9.atom_names[j].startswith('C'):
            is_Ctor = False
    if is_Ctor:
        Ctor.append(i)

# load data
remd_dict = load_obj('../local_data/out/hydrocarbon_cyc9/remd_data.pkl')
traj = mdtraj.Trajectory(
    remd_dict['trajs'][0].reshape(remd_dict['trajs'][0].shape[0],
                                  toppar_cyc9.natoms, 3), top_cyc9)
traj = traj[10000:14000]
traj = traj.superpose(traj[0])
xtrain = traj.xyz.reshape(
    (traj.xyz.shape[0], traj.xyz.shape[1] * traj.xyz.shape[2]))

network_resample = create_RealNVPNet(mm_cyc9, nlayers=4, nl_activation='tanh')
resample(mm_cyc9,
         Ctor,
         network_resample,
         xtrain,
         traj[0],
         epochsML=300,