How to run the code
Closed this issue · 5 comments
I ran your implement code of Chorus
my running cmd is
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr 5e-4 --l2 1e-5 --epoch 50 --early_stop 0 --batch_size 512 --dataset 'Grocery_and_Gourmet_Food' --stage 1
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr_scale 0.1 --lr 1e-3 --l2 0 --dataset 'Grocery_and_Gourmet_Food' --base_method 'BPR' --stage 2
The errors message is as follows:
Load corpus from ../data/Grocery_and_Gourmet_Food/KGReader.pkl
#params: 1521509
Chorus(
(u_embeddings): Embedding(14682, 64)
(i_embeddings): Embedding(8714, 64)
(r_embeddings): Embedding(3, 64)
(betas): Embedding(57, 3)
(mus): Embedding(57, 3)
(sigmas): Embedding(57, 3)
(prediction): Linear(in_features=64, out_features=1, bias=False)
(user_bias): Embedding(14682, 1)
(item_bias): Embedding(8714, 1)
(kg_loss): MarginRankingLoss()
)
Traceback (most recent call last):
File "main.py", line 116, in
main()
File "main.py", line 66, in main
model.actions_before_train()
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/models/sequential/Chorus.py", line 76, in actions_before_train
raise ValueError('Pre-trained KG model does not exist, please run with "--stage 1"')
ValueError: Pre-trained KG model does not exist, please run with "--stage 1"
I was wondering whether the difference was made due to my negligence. Looking forward to your reply! Thanks!
The two stages should be run in a separate fashion:
First run the stage-1 cmd:
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr 5e-4 --l2 1e-5 --epoch 50 --early_stop 0 --batch_size 512 --dataset 'Grocery_and_Gourmet_Food' --stage 1
Then run the stage-2 cmd:
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr_scale 0.1 --lr 1e-3 --l2 0 --dataset 'Grocery_and_Gourmet_Food' --base_method 'BPR' --stage 2
Thank you for your reply!
I ran your implement code of Chorus, the cmd is
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr 5e-4 --l2 1e-5 --epoch 50 --early_stop 0 --batch_size 512 --dataset 'Grocery_and_Gourmet_Food' --stage 1
The errors message is as follows:
Traceback (most recent call last):
File "main.py", line 116, in
main()
File "main.py", line 78, in main
runner.train(data_dict)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/helpers/BaseRunner.py", line 122, in train
dev_result = self.evaluate(data_dict['dev'], self.topk[:1], self.metrics)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/helpers/BaseRunner.py", line 190, in evaluate
predictions = self.predict(data)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/helpers/BaseRunner.py", line 214, in predict
prediction = data.model(utils.batch_to_gpu(batch, data.model.device))['prediction']
File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/models/sequential/Chorus.py", line 96, in forward
prediction = self.rec_forward(feed_dict)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/models/sequential/Chorus.py", line 135, in rec_forward
temporal_decay = self.kernel_functions(r_interval * mask, betas, sigmas, mus)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/models/sequential/Chorus.py", line 117, in kernel_functions
decay = exp_dist.log_prob(delta_t).exp()
File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/distributions/exponential.py", line 62, in log_prob
self._validate_sample(value)
File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/distributions/distribution.py", line 277, in _validate_sample
raise ValueError('The value argument must be within the support')
I was wondering whether the difference was made due to my negligence. Looking forward to your reply! Thanks!
ValueError: The value argument must be within the support
It seems that PyTorch 1.8 turns on argument validation by default for various distributions. You can pass validate_args=False
to the constructor by changing line 116 to:
exp_dist = torch.distributions.exponential.Exponential(beta, validate_args=False)
Hi, thanks for your reply!
I wanted to run your implement code on ML-1M dataset, the stage 1 cmd:
python main.py --model_name Chorus --emb_size 64 --margin 1 --lr 5e-4 --l2 1e-5 --epoch 50 --early_stop 0 --batch_size 512 --dataset 'ml-1m' --stage 1
The errors message is as follows:
GPU available: True
Load corpus from ../data/ml-1m/KGReader.pkl
#params: 633751
Chorus(
(u_embeddings): Embedding(6041, 64)
(i_embeddings): Embedding(3707, 64)
(r_embeddings): Embedding(1, 64)
(betas): Embedding(1, 1)
(mus): Embedding(1, 1)
(sigmas): Embedding(1, 1)
(prediction): Linear(in_features=64, out_features=1, bias=False)
(user_bias): Embedding(6041, 1)
(item_bias): Embedding(3707, 1)
(kg_loss): MarginRankingLoss()
)
Optimizer: Adam
Traceback (most recent call last):
File "main.py", line 116, in
main()
File "main.py", line 78, in main
runner.train(data_dict)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/helpers/BaseRunner.py", line 114, in train
loss = self.fit(data_dict['train'], epoch=epoch + 1)
File "/home/zlc/zlc/lhz/DIDN/ReChorus/src/helpers/BaseRunner.py", line 166, in fit
dl = DataLoader(data, batch_size=self.batch_size, shuffle=True, num_workers=self.num_workers,
File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 270, in init
sampler = RandomSampler(dataset, generator=generator) # type: ignore[arg-type]
File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/utils/data/sampler.py", line 102, in init
raise ValueError("num_samples should be a positive integer "
ValueError: num_samples should be a positive integer value, but got num_samples=0
I was wondering whether the difference was made due to my negligence. Looking forward to your reply! Thanks!
The Chorus model cannot run on the ML-1M dataset because there is no information about item relations like Amazon (e.g., complement, substitute).