Ejemplo n.º 1
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, 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)
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
Ejemplo n.º 3
0
        sample=flags.sample)


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, features, edges = load_data(hparams.graph_file, hparams.nodes)
    num_nodes = adj[0].shape[0]
    num_features = features[0].shape[1]
    #print("Debug", num_nodes, adj[0][0])
    # Training
    model = VAEG(hparams, placeholders, num_nodes, num_features, edges)
    # model.restore(hparams.out_dir)
    model.initialize()
    model.train(placeholders, hparams, adj, features)

    # Test code
    '''
    model2 = VAEG(hparams, placeholders, 30, 1)
    model2.restore(hparams.out_dir)
    hparams.sample = True
    i = 0
    G_good = load_embeddings(hparams.z_dir+'train0.txt')
    G_bad = load_embeddings(hparams.z_dir+'test_11.txt')
    
    #model2.sample_graph_slerp(hparams, placeholders, 5, G_good, G_bad, num=29)
    
Ejemplo n.º 4
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")
Ejemplo n.º 5
0
      sample=flags.sample,
      neg_sample_size=flags.neg_sample_size,
      node_sample=flags.node_sample,
      bfs_sample=flags.bfs_sample
      )

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, = load_data_new(hparams.graph_file, hparams.nodes, hparams.node_sample, hparams.bfs_sample, hparams.bin_dim)
    num_nodes = adj[0].shape[0]
    num_features = features[0].shape[1]
    lenedges = [len(edge[0]) for edge in edges]
    lenweight_bin = [len(weight_b[0]) for weight_b in weight_bin]
    print("Len edges", lenedges, lenweight_bin)
    print("Num features", num_features)
    print("Num examples", len(adj))
    #print("Neg_index", neg_index) 
    e = max([len(edge) for edge in edges])
        
    log_fact_k = log_fact(e)
    # Training
    #'''
    model = VAEG(hparams, placeholders, num_nodes, num_features,log_fact_k, len(adj))
    model.restore(hparams.out_dir)
    model.train(placeholders, hparams, adj, weight, weight_bin, features, edges, neg_edges, features1)