if __name__ == '__main__':
    nmt_parser = argparse.ArgumentParser()
    add_arguments(nmt_parser)
    FLAGS, unparsed = nmt_parser.parse_known_args()
    hparams = create_hparams(FLAGS)
    
    # loading the data from a file
    adj, weight, weight_bin, features, edges, hde = load_data(hparams.graph_file, hparams.nodes, hparams.bin_dim)

    #Test code
    #'''
    e = max([len(edge) for edge in edges])
    n_f = len(features[0][0])
    log_fact_k = log_fact(e) 
    model2 = VAEG(hparams, placeholders, hparams.nodes, n_f, edges, log_fact_k, hde)
    model2.restore(hparams.out_dir)
    latent_points = []
    '''
    for i1 in range(len(adj)):
        sample1 = model2.getembeddings(hparams, placeholders, adj[i1], features[i1], weight_bin[i1], weight[i1])
        latent_points.append(np.reshape(np.array(sample1), -1))
    '''
    #np.savetxt("latent_features.txt", np.array(latent_points))
    
    #sample
    i = 0
    while i < 1:
        model2.sample_graph(hparams, placeholders,adj, features, weight, weight_bin, i+hparams.offset, hde, hparams.nodes, hparams.edges)
        i += 1

示例#2
0
文件: sample.py 项目: xxffliu/nevae
    adj, features, edges = load_data(hparams.graph_file, hparams.nodes)

    num_nodes = adj[0].shape[0]

    #Test code
    #''' interpolation

    model2 = VAEG(hparams, placeholders, hparams.nodes, 1, edges)
    model2.restore(hparams.out_dir)
    #hparams.sample = True

    i = 0
    '''
    # getting embeddings
    sample_1 = model2.getembeddings(hparams, placeholders, adj[i], features[i])
    '''
    '''
    sample_1 = model2.getembeddings(hparams, placeholders, adj[0], features[0]) 
    sample_2 = model2.getembeddings(hparams, placeholders, adj[1], features[1])
    
    while i < 1:
        model2.sample_graph_slerp(hparams, placeholders, i,sample_1, sample_2, "slerp", (i+1)*0.1, num=70)
        model2.sample_graph_slerp(hparams, placeholders, i,sample_1, sample_2, "lerp", (i+1)*0.1, num=70)
        i+=1
    '''
    #''' sampling
    while i < 100:
        model2.sample_graph(hparams, placeholders, i + hparams.offset,
                            hparams.nodes, hparams.edges)
        i += 1
示例#3
0
if __name__ == '__main__':
    nmt_parser = argparse.ArgumentParser()
    add_arguments(nmt_parser)
    FLAGS, unparsed = nmt_parser.parse_known_args()
    hparams = create_hparams(FLAGS)
    # loading the data from a file
    adj, weight, weight_bin, features, edges, neg_edges, features1, smiles = load_data_new(
        hparams.graph_file, hparams.nodes, 1, 1, hparams.bin_dim)

    #Test code
    e = max([len(edge) for edge in edges])
    n_f = len(features[0][0])
    log_fact_k = log_fact(e)

    model2 = VAEG(hparams, placeholders, hparams.nodes, n_f, log_fact_k,
                  len(adj))
    model2.restore(hparams.out_dir)
    while i < 100:
        smiles = []
        smiles_new = model2.sample_graph(hparams, placeholders, adj, features,
                                         features1, weight, weight_bin, edges,
                                         i)
        for s in smiles_new:
            if s != 'None':
                smiles.append(s)
        i += 1
        print smiles
        with open(hparams.sample_file + "smiles.txt", "a") as f:
            for s in smiles:
                f.write(s + "\n")