Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it really work?Is it better than a randomly generated vector #2

Open
freedomRen opened this issue Nov 5, 2020 · 0 comments
Open

Comments

@freedomRen
Copy link

freedomRen commented Nov 5, 2020

def get_subgraph_embedding(embeddings_model_file):
    embedding_word_size = 0
    embedding_dims = 0
    word_embeddings = {}
    print("Loading embedding model %s" %(embeddings_model_file))
    with open(embeddings_model_file) as fh:
        # skip first line
        embedding_word_size, embedding_dims = fh.readline().rstrip().split()
        embedding_word_size = int(embedding_word_size)
        embedding_dims = int(embedding_dims)
        print('sub2Vec Info : %d X %d' %(embedding_word_size, embedding_dims))

        for line in fh.readlines():
            values = line.rstrip().split()
            word = values[0]
            # embedding = np.asarray(values[1:], dtype=np.float64)
            rand_seed = np.uint32(hash(word))
            np.random.seed(rand_seed)
            embedding = np.random.randn(embedding_dims)
            word_embeddings[word] = embedding

    return embedding_word_size, embedding_dims, word_embeddings

I change it to py3, and using randomly generated vectors,and got better result。
So I'm trying to keep thinking scientifically.
Use subgraphs to encode the full graph,
Does the vector of the subgraph have to be important,that we got it from skipgram or randomly generated vector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant