'How to obtain Node2Vec vectors all of the nodes?

I have tried nodevectors , fastnode2vec. But I cannot get vectors of all nodes. Why? e.g.

The code is

from fastnode2vec import Node2Vec

graph = Graph(_lst, directed=True, weighted=True)

model = Node2Vec(_graph, dim=300, walk_length=100, context=10, p=2.0, q=0.5, workers=-1)

model.train(epochs=epochs)

I have 10,000 nodes. When I check:

model.index_to_key

there are only 502 nodes. Why is that? How to set parameters so I can get the vectors of all nodes?



Solution 1:[1]

It's possible that your settings are not generating enough appearances of all nodes to meet other requirements for inclusion, such as the min_count=5 used by the related Word2Vec superclass to discard tokens with too few example usages to model well.

See this other related answer for related considerations & possible fixes (though in the context of the nodevectors package rather than the fastnode2vec package you're using):

nodevectors not returning all nodes

If that doesn't help resolve your issue, you should include more details about your graph - such as demonstrating via displayed output that it really has 10,000 nodes, & they're all sufficiently conneted, & that the random-walks generated by your node2vec library sufficiently revisit all of them for the training purposes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gojomo