我需要执行以下操作:
node2vec
中创建随机漫游 我的问题
在pycharm
上导入这些路径之后,我不知道如何将bpmn
中的图形传递到node2vec
。
关于如何解决这个问题的任何想法?
``
(python
import networkx as nx
from node2vec import Node2Vec
import gensim
import word2vec
# Create a graph
graph ='P1.bpmn'
# Precompute probabilities and generate walks - **ON WINDOWS ONLY WORKS WITH workers=1**
node2vec = Node2Vec(graph, dimensions=64, walk_length=3, num_walks=2, workers=1) # Use temp_folder for big graphs
# Embed nodes
model = node2vec.fit(window=10, min_count=1, batch_words=4) # Any keywords acceptable by gensim.Word2Vec can be passed, `diemnsions` and `workers` are automatically passed (from the Node2Vec constructor)
# Save embeddings for later use
model.wv.save_word2vec_format('Random_Walk')
# Save model for later use
model.save('Random_MODEL_Walk') )
``
答案 0 :(得分:0)
您不能将字符串('P1.bpmn'
)传递到Node2Vec
构造函数中。它接受networkx
图。您应该先创建一个networkx
图,然后才能使用Node2Vec
构造函数