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

怎么样提高模型评估阶段的速度 #8

Open
somTian opened this issue Nov 2, 2019 · 4 comments
Open

怎么样提高模型评估阶段的速度 #8

somTian opened this issue Nov 2, 2019 · 4 comments

Comments

@somTian
Copy link

somTian commented Nov 2, 2019

在这个代码中,模型每次迭代后,都会计算模型的指标。但是好像速度很慢,我的用户和产品都是10K+,用MF模型训练需要100s,但是每次计算指标都需要700s

@ZhongchuanSun
Copy link
Collaborator

库中有cpp并行版本测试的代码, 在命令行中切换库的根目录, 然后使用'python setup.py build_ext --inplace'命令编译cpp代码, 编译成功之后会自动使用cpp版本的测试

@somTian
Copy link
Author

somTian commented Nov 3, 2019

来点赞了,根据您的建议,测试速度确实提高了很多

@somTian
Copy link
Author

somTian commented Nov 5, 2019

库中有cpp并行版本测试的代码, 在命令行中切换库的根目录, 然后使用'python setup.py build_ext --inplace'命令编译cpp代码, 编译成功之后会自动使用cpp版本的测试

您好,根据您的建议,我在使用框架里的算法的时候,速度快了很多,但是在我自己的模型上跑的时候,并没有提高速度,测试阶段CPU一直在100%,好像并没有并行,请问这是什么原因呢

@ZhongchuanSun
Copy link
Collaborator

自己的模型需要实现predict(user_ids, items=None)接口, 测试器通过调用这个接口来实现测试. user_ids是一批用户(一维数组或list), items是None或二维数组(或list). 当items为None时, 需要返回用户对所有物品的评分; 如果items不为None, 此时len(items)==len(user_ids), 只需返回用户对对应物品的评分即可.
cpp加速的地方是得到评分信息后, 计算评价指标时的部分; 如果模型在预测评分时比较慢,则需要优化这部分代码了.

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

2 participants