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

process_raw_pred方法计算逻辑 #47

Open
hemengjita opened this issue Aug 9, 2024 · 0 comments
Open

process_raw_pred方法计算逻辑 #47

hemengjita opened this issue Aug 9, 2024 · 0 comments

Comments

@hemengjita
Copy link

首先非常感谢贵校提供的代码,我在看这段的时候有点疑问,不知道是不是代码逻辑问题呢🙋

def process_raw_pred(raw_question_matrix, raw_pred, num_questions: int) -> tuple:
questions = torch.nonzero(raw_question_matrix)[1:, 1] % num_questions ##torch.nonzero(raw_question_matrix)[1:, 1]表示raw_question_matrix中非0的位置,即用户的有效回答
length = questions.shape[0]
pred = raw_pred[: length]
pred = pred.gather(1, questions.view(-1, 1)).flatten()
truth = torch.nonzero(raw_question_matrix)[1:, 1] // num_questions #truth表示真实作答情况,0表示回答正确,1表示回答错误,与原始数据相反?
# truth = 1 - truth#这里逻辑是不是写错了!! 0表示回答正确,1表示回答错误,与原始数据相反?

return pred, truth

关键在这里➡️
truth = torch.nonzero(raw_question_matrix)[1:, 1] // num_questions
比如one -hot encode后 125错了 numofq=100 那就是encode_q[125]=1 ,但是还原时候,125//100 =1 ,这代表的是回答正确呀?

希望您的解答,谢谢

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

1 participant