Knowledge_Graph_based_Intent_Network icon indicating copy to clipboard operation
Knowledge_Graph_based_Intent_Network copied to clipboard

训练过程报错“name 'test_user_set' is not defined”

Open HFUTZWJ opened this issue 3 years ago • 9 comments

您好,最近在学习该工作的代码,通过调用给出的命令行参数,训练过程中evaluate.py文件的test_one_user(x)函数,在“user_pos_test = test_user_set[u]”处报错“name 'test_user_set' is not defined”。调试了一段时间没有找到出错的原因,想请问一下您是否知道原因?

HFUTZWJ avatar Oct 15 '21 11:10 HFUTZWJ

您好。这个bug我也不太确定呢,我并没遇到,您能分享下您的操作系统环境、Python版本之类的信息吗?

huangtinglin avatar Oct 23 '21 02:10 huangtinglin

我之前在window上遇到过,应该是操作系统的问题,windows系统多进程那里有问题,把多进程那里拆开写就好了,或者换到linux

Aristomd avatar Nov 01 '21 13:11 Aristomd

我之前在window上遇到过,应该是操作系统的问题,windows系统多进程那里有问题,把多进程那里拆开写就好了,或者换到linux

您好,我在windows上也遇到了这个问题,请问您具体是怎么操作的呢?

JbwFrank avatar Nov 18 '21 11:11 JbwFrank

用Linux系统就不会报错了

changqingla avatar Dec 22 '21 12:12 changqingla

我之前在window上遇到过,应该是操作系统的问题,windows系统多进程那里有问题,把多进程那里拆开写就好了,或者换到linux

您好,我在windows上也遇到了这个问题,请问您具体是怎么操作的呢?

我也遇到了同样的问题,想问您一下是怎么解决的,如何把多线程那里拆开写

QianGuYiDi avatar Mar 03 '22 03:03 QianGuYiDi

我之前在window上遇到过,应该是操作系统的问题,windows系统多进程那里有问题,把多进程那里拆开写就好了,或者换到linux

想问一下具体该怎样把多线程那里拆开写呢?

QianGuYiDi avatar Apr 23 '22 02:04 QianGuYiDi

您好,最近在学习该工作的代码,通过调用给出的命令行参数,训练过程中evaluate.py文件的test_one_user(x)函数,在“user_pos_test = test_user_set[u]”处报错“name 'test_user_set' is not defined”。调试了一段时间没有找到出错的原因,想请问一下您是否知道原因?

您好,您的问题解决了吗?是怎样解决的?

QianGuYiDi avatar Apr 23 '22 02:04 QianGuYiDi

这里batch_result = pool.map(test_one_user, user_batch_rating_uid)不要用多进程,改一下test_one_user函数,具体我也忘了,windows多进程下全局变量不共享,或者更简单的换到linux上不报错

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年4月23日(星期六) 上午10:06 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [huangtinglin/Knowledge_Graph_based_Intent_Network] 训练过程报错“name 'test_user_set' is not defined” (#16)

您好,最近在学习该工作的代码,通过调用给出的命令行参数,训练过程中evaluate.py文件的test_one_user(x)函数,在“user_pos_test = test_user_set[u]”处报错“name 'test_user_set' is not defined”。调试了一段时间没有找到出错的原因,想请问一下您是否知道原因?

您好,您的问题解决了吗?是怎样解决的?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Aristomd avatar Apr 24 '22 01:04 Aristomd

def test_one_user(x):
# user u's ratings for user u
rating = x[0]
# uid
u = x[1]
# user u's items in the training set
try:
training_items = train_user_set[u]
except KeyError:
training_items = []
# user u's items in the test set
user_pos_test = test_user_set[u]
all_items = set(range(0, n_items))
test_items = list(all_items - set(training_items))
# Assuming ranklist_by_heapq and ranklist_by_sorted are available
# and Ks is a global variable or passed as a parameter
if args.test_flag == 'part':
r, auc = ranklist_by_heapq(user_pos_test, test_items, rating, Ks)
else:
r, auc = ranklist_by_sorted(user_pos_test, test_items, rating, Ks)
return get_performance(user_pos_test, r, auc, Ks) 168行改为: batch_result = [test_one_user(x) for x in user_batch_rating_uid]

15715558546 avatar Feb 28 '24 11:02 15715558546