rsonthal/TreeRep

Generate hyperbolic embeddings for TreeRep

jiag19 opened this issue · 1 comments

Hi, thanks for sharing your great work. I'm trying to generate hyperbolic embeddings for the learned tree strucutre by TreeRep. I understand that we need to use codes from https://github.com/HazyResearch/hyperbolics. But it seems to require only the original graph edges as input, and learns the tree structure as its intermediate result, so how can we input TreeRep's outputs into the above codes and generate hyperbolic emebddings? Would you mind give some instructions and your parameter setting for training HazyResearch's model? Thanks. @rsonthal

You need to use the comb.jl code in the combinatorial folder. To save a TreeRep output in that format do the following:

G, W = TreeRep.metric_to_structure(....)

filename = "foo.edges"
open(filename, "w") do f
    for e in edges(G)
        i = e.src - 1
        j = e.dst - 1
        w = W[i+1,j+1]
        if w < 0
            w = 0
        end
        write(f, "$i $j $w\n")
    end
end

This will create a file with the name foo.edges. Then to run the HazyResearch code follow the example in their repository. Specifically,

"Julia script to perform the combinatorial embedding.

usage: comb.jl -d DATASET -e EPS [-r DIM] [-s] [-m EMBEDDING-SAVE]
[-v] [-t SCALE] [-c] [-z STATS-SAMPLE] [-p PRECISION]
[-h]"

where dataset is now replaced with a path to the foo.edges file.