擅长:python、mysql、java
<p>我建议您使用<a href="https://github.com/stellargraph/stellargraph" rel="nofollow noreferrer">stellargraph library</a>,它为机器学习提供了很好的图形算法。例如基本的Node2Vec。。。在</p>
<pre><code>from stellargraph.data import BiasedRandomWalk
from stellargraph import StellarGraph
from gensim.models import Word2Vec
rw = BiasedRandomWalk(StellarGraph(g_nx))
walks = rw.run(
nodes=list(g_nx.nodes()), # root nodes
length=100, # maximum length of a random walk
n=10, # number of random walks per root node
p=0.5, # Defines (unormalised) probability, 1/p, of returning to source node
q=2.0 # Defines (unormalised) probability, 1/q, for moving away from source node
)
model = Word2Vec(walks, size=128, window=5, min_count=0, sg=1, workers=2, iter=1)
model.wv['29']
</code></pre>