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

Graph4Rec模板文件执行出问题 #449

Open
xinDongY opened this issue Aug 3, 2022 · 2 comments
Open

Graph4Rec模板文件执行出问题 #449

xinDongY opened this issue Aug 3, 2022 · 2 comments

Comments

@xinDongY
Copy link

xinDongY commented Aug 3, 2022

运行如下代码时总是报错
node_types_file = "./rec_data/node_types.txt"
edges_file = "./rec_data/user2movie.txt"
embed_path = "./env_run/src/save_embed/embedding.txt"
movie_name_file = "./rec_data/nid2movieName.txt"

nid2type = load_vocab(node_types_file)
movie2vec, vec_dim = load_embed(embed_path, nid2type, dtype="movie")
user2vec, _ = load_embed(embed_path, nid2type, dtype="user")

print("building ann tree")
annIndex = AnnTree(user2vec, vec_dim)

print("loading user2likedMovies")
user2likedMovies = load_user2movies(edges_file)

print("loading movie2name")
movie2name = load_movie2name(movie_name_file)


报错如下

UnboundLocalError Traceback (most recent call last)
/tmp/ipykernel_199/1169641705.py in
8 nid2type = load_vocab(node_types_file)
9 movie2vec, vec_dim = load_embed(embed_path, nid2type, dtype="movie")
---> 10 user2vec, _ = load_embed(embed_path, nid2type, dtype="user")
11
12 print("building ann tree")

~/Graph4Rec/evaluation/evaluation.py in load_embed(embed_file, metaID2type, dtype)
48 embed = [float(i) for i in fields[1].split(" ")]
49 nodeID2vec[node_id] = embed
---> 50 vec_dim = len(embed)
51
52 return nodeID2vec, vec_dim

UnboundLocalError: local variable 'embed' referenced before assignment

不清楚为何内置函数的变量会被分配。感谢解答

@Liwb5
Copy link
Collaborator

Liwb5 commented Sep 20, 2022

你的embedding 文件是空的吧。

@Liwb5
Copy link
Collaborator

Liwb5 commented Sep 20, 2022

可能是因为你没有启动图引擎就开始训练,这样就没有节点被训练到,embedding文件就是空的。

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