yusanshi / news-recommendation

Implementations of some methods in news recommendation.
MIT License
241 stars 50 forks source link

I want to run one of the models, how should I configure it #21

Closed LXXiaogege closed 3 years ago

LXXiaogege commented 3 years ago

I want to run one of the models, how should I configure it?thank you

yusanshi commented 3 years ago

From README.md:

Modify src/config.py to select target model. The configuration file is organized into general part (which is applied to all models) and model-specific part (that some models not have).

The general part should be self-explanatory, e.g., batch size, learning rate, etc. For model-specific part, you should refer to the experiment section of that paper.

But I believe the default config is enough for a quick start. So you can just select the model in src/config.py.

LXXiaogege commented 3 years ago

For example: I train a LSTRU model, but I don't want to train other models(NRMS....). what i need to do?

yusanshi commented 3 years ago

See https://github.com/yusanshi/NewsRecommendation/blob/master/src/config.py#L3-L7.

Just set model_name as 'LSTRU'.

LXXiaogege commented 3 years ago

thank you 😁------------------ 原始邮件 ------------------ @.> 发送时间: 2021年8月28日(星期六) 晚上10:51 @.>; @.**@.>; 主题: Re: [yusanshi/NewsRecommendation] 我想运行其中一个模型,应该如何配置 (#21)

LXXiaogege commented 3 years ago

When i set model_name as 'LSTRU' or ‘NAML’,The program will report an error:

Training: 0%| | 0/50426 [00:00<?, ?it/s] Traceback (most recent call last): File "train.py", line 294, in train() File "train.py", line 185, in train minibatch["clicked_news"]) File "/root/miniconda3/envs/newsRec/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, kwargs) File "/root/lvxin/NewsRecommendation/src/model/LSTUR/init.py", line 70, in forward [self.news_encoder(x) for x in candidate_news], dim=1) File "/root/lvxin/NewsRecommendation/src/model/LSTUR/init.py", line 70, in [self.news_encoder(x) for x in candidate_news], dim=1) File "/root/miniconda3/envs/newsRec/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/root/lvxin/NewsRecommendation/src/model/LSTUR/news_encoder.py", line 53, in forward news['subcategory'].to(device)) File "/root/miniconda3/envs/newsRec/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, kwargs) File "/root/miniconda3/envs/newsRec/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 160, in forward self.norm_type, self.scale_grad_by_freq, self.sparse) File "/root/miniconda3/envs/newsRec/lib/python3.6/site-packages/torch/nn/functional.py", line 2043, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) IndexError: index out of range in self

yusanshi commented 3 years ago

Have you done this? (taken from README.md)

Remember you shoud modify num_* in src/config.py by the output of src/data_preprocess.py

PS: you should open a new issue for this, since it is irrelevant to the subject of the current issue.

yusanshi commented 3 years ago

Close inactive issue. Reopen it if needed.