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

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

Open
HFUTZWJ opened this issue Oct 15, 2021 · 10 comments
Open

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

HFUTZWJ opened this issue Oct 15, 2021 · 10 comments

Comments

@HFUTZWJ
Copy link

HFUTZWJ commented Oct 15, 2021

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

@huangtinglin
Copy link
Owner

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

@Aristomd
Copy link

Aristomd commented Nov 1, 2021

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

@JbwFrank
Copy link

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

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

@changqingla
Copy link

用Linux系统就不会报错了

@QianGuYiDi
Copy link

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

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

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

@QianGuYiDi
Copy link

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

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

@QianGuYiDi
Copy link

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

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

@Aristomd
Copy link

Aristomd commented Apr 24, 2022 via email

@15715558546
Copy link

15715558546 commented Feb 28, 2024

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]

@AgentGit123
Copy link

def test_one_user(x): # 用户 u 对用户 u 的评分 rating = x[0] # uid u = x[1] # 训练集中用户 u 的项目 try: training_items = train_user_set[u] except KeyError: training_items = [] # 用户 u 在测试集中的项目 user_pos_test = test_user_set[u] all_items = set(range(0, n_items)) test_items = list(all_items - set(training_items)) # 假设 ranklist_by_heapq 和 ranklist_by_sorted 都可用 # 并且 Ks 是全局变量或作为参数传递 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]

牛的,哥

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

No branches or pull requests

9 participants