Exemplo n.º 1
0
dim_edge = DE.shape[3]
dim_y = DY.shape[1]

atom_list = ['B', 'C', 'N', 'O', 'F', 'Si', 'P', 'S', 'Cl', 'Se', 'Br', 'I']
bond_list = ['SINGLE', 'DOUBLE', 'TRIPLE']
bpatt_dim = [3, 3, 2, 1, 2, 1]

print(':: preprocess data')
scaler = StandardScaler()
scaler.fit(DY)
DY = scaler.transform(DY)

mu_prior = np.mean(DY, 0)
cov_prior = np.cov(DY.T)

model = Model(n_node, dim_node, dim_edge, dim_y, atom_list, bpatt_dim,
              mu_prior, cov_prior)

print(':: generate molecular graphs')
with model.sess:
    model.saver.restore(model.sess, save_path)
    total_count, valid_count, novel_count, unique_count, genmols = model.test(
        10000, 0, Dsmi)

valid = valid_count / total_count
unique = unique_count / valid_count
novel = novel_count / valid_count

print(':: Valid:', valid * 100, 'Unique:', unique * 100, 'Novel:', novel * 100,
      'GMean:', 100 * (valid * unique * novel)**(1 / 3))
Exemplo n.º 2
0

n_node = DV.shape[1]
dim_node = DV.shape[2]
dim_edge = DE.shape[3]
dim_y = DY.shape[1]

print(':: preprocess data')
scaler = StandardScaler()
scaler.fit(DY)
DY = scaler.transform(DY)

mu_prior=np.mean(DY,0)   
cov_prior=np.cov(DY.T)             

model = Model(n_node, dim_node, dim_edge, dim_y, mu_prior, cov_prior)

print(':: generate molecular graphs')
with model.sess:
    model.saver.restore(model.sess, save_path)     

    # unconditional generation     
    total_count, valid_count, novel_count, unique_count, genmols = model.test(10000, 0, Dsmi, atom_list)

    valid=valid_count/total_count
    unique=unique_count/valid_count
    novel=novel_count/valid_count

    list_Y=[]
    for m in genmols:
        mol = Chem.MolFromSmiles(m)
Exemplo n.º 3
0
data_path = './' + data + '_graph.pkl'
save_dict = './'

print(':: load data')
with open(data_path, 'rb') as f:
    [DV, DE, DY, Dsmi] = pkl.load(f)

DV = DV.todense()
DE = DE.todense()
DY = DY

n_node = DV.shape[1]
dim_node = DV.shape[2]
dim_edge = DE.shape[3]
dim_y = DY.shape[1]

print(':: preprocess data')
scaler = StandardScaler()
scaler.fit(DY)
DY = scaler.transform(DY)

mu_prior = np.mean(DY, 0)
cov_prior = np.cov(DY.T)

model = Model(n_node, dim_node, dim_edge, dim_y, mu_prior, cov_prior)

print(':: train model')
with model.sess:
    load_path = None
    save_path = save_dict + data + '_model.ckpt'
    model.train(DV, DE, DY, Dsmi, atom_list, load_path, save_path)