Comments (3)
上面的问题我发现是由于你们Config的设置上似乎出现了点问题,这里的config = Config(model=DuoRec, dataset=dataset, config_file_list=config_file_list)
DuoRec不能以model_name='DuoRec'
的参数形式传进去,否则将会报错,对于自定义的模型不能通过传model=model_name
来调用,只能直接以model=Customize model name
这个形式调用。但是这里出现了另一个问题,请问这里的sem_aug
是哪里出现的呢,我看DuoRec的source code,发现他们的实现似乎除了模型以及配置文件外,其余都与recbole的默认文件保持一致。如果我哪里出现了错误,劳烦指正我一下,谢谢!O(∩_∩)O
Traceback (most recent call last):
File "/home/xiaolongtao/UniSRec/run_baseline.py", line 96, in <module>
baseline_func(model=args.model, dataset=args.dataset, config_file_list=config_file_list)
File "/home/xiaolongtao/UniSRec/run_baseline.py", line 64, in run_baseline
best_valid_score, best_valid_result = trainer.fit(
File "/home/xiaolongtao/anaconda3/envs/UniSRec/lib/python3.9/site-packages/recbole/trainer/trainer.py", line 439, in fit
train_loss = self._train_epoch(
File "/home/xiaolongtao/anaconda3/envs/UniSRec/lib/python3.9/site-packages/recbole/trainer/trainer.py", line 245, in _train_epoch
losses = loss_func(interaction)
File "/home/xiaolongtao/UniSRec/baselines/duorec.py", line 190, in calculate_loss
sem_aug, sem_aug_lengths = interaction['sem_aug'], interaction['sem_aug_lengths']
File "/home/xiaolongtao/anaconda3/envs/UniSRec/lib/python3.9/site-packages/recbole/data/interaction.py", line 135, in __getitem__
return self.interaction[index]
KeyError: 'sem_aug'
from recbole.
@XiaoLongtaoo 你好!
这里的sem_aug
是soure code写在dataloader的duorec_aug
用于数据增强的部分
from recbole.
@XiaoLongtaoo 你好! 这里的
sem_aug
是soure code写在dataloader的duorec_aug
用于数据增强的部分
我找到了这个数据增强办法,但是这里仍然存在一个问题,当我将它用在我自己的dataloader中时,代码如下所示:
def duorec_aug(self, cur_data, index, interaction):
cur_same_target = self.same_target_index[index]
null_index = []
sample_pos = []
for i, targets in enumerate(cur_same_target):
# in case there is no same-target sequence
# don't know why this happens since the filtering has been applied
if len(targets) == 0:
sample_pos.append(-1)
null_index.append(i)
else:
sample_pos.append(np.random.choice(targets))
sem_pos_seqs = self.static_item_id_list[sample_pos]
sem_pos_lengths = self.static_item_length[sample_pos]
if null_index:
sem_pos_seqs[null_index] = cur_data['item_id_list'][null_index]
sem_pos_lengths[null_index] = cur_data['item_length'][null_index]
cur_data.update(Interaction({'sem_aug': sem_pos_seqs, 'sem_aug_lengths': sem_pos_lengths}))
return cur_data
训练时所用的dataloader代码如下:
class CustomizedTrainDataLoader(TrainDataLoader):
def __init__(self, config, dataset, sampler, shuffle=False):
super().__init__(config, dataset, sampler, shuffle=shuffle)
self.transform = construct_transform(config)
self.model = config['model']
"special parameters for DuoRec"
if self.model == 'DuoRec':
self.same_target_index = dataset.same_target_index
self.static_item_id_list = dataset.static_item_id_list
self.static_item_length = dataset.static_item_length
# self.static_item_id_list = self.dataset.inter_feat['item_id_list']
# self.static_item_length = self.dataset.inter_feat['item_length']
""""""
def _next_batch_data(self):
cur_data = super()._next_batch_data()
# index = cur_data.index()
index = slice(self.pr - self.step, self.pr)
""""""
if self.model == 'DuoRec':
cur_data = self.duorec_aug(self, cur_data, index)
return cur_data
""""""
else:
transformed_data = self.transform(self, cur_data)
return transformed_data
def duorec_aug(self, cur_data, index, interaction):
cur_same_target = self.same_target_index[index]
null_index = []
sample_pos = []
for i, targets in enumerate(cur_same_target):
# in case there is no same-target sequence
# don't know why this happens since the filtering has been applied
if len(targets) == 0:
sample_pos.append(-1)
null_index.append(i)
else:
sample_pos.append(np.random.choice(targets))
sem_pos_seqs = self.static_item_id_list[sample_pos]
sem_pos_lengths = self.static_item_length[sample_pos]
if null_index:
sem_pos_seqs[null_index] = cur_data['item_id_list'][null_index]
sem_pos_lengths[null_index] = cur_data['item_length'][null_index]
cur_data.update(Interaction({'sem_aug': sem_pos_seqs, 'sem_aug_lengths': sem_pos_lengths}))
return cur_data
请问为什么读取训练数据时仍然不会更新,数据中还是没有出现sem_aug
, sem_aug_lengths
这两个属性,请问这是哪里出现了问题呢?感谢!
from recbole.
Related Issues (20)
- 请问现在伯乐支持少样本学习吗?
- [🐛BUG] LightGCN在ml-100k数据集上性能不佳 HOT 6
- Parameters of HyperTuning
- [🐛BUG] Error running LightGCN
- [🐛BUG] 顺序推荐模型在使用带有label标签的数据集并且使用排序评价指标(如NDCG)的时候会发生报错。 HOT 2
- 数据集想加入除了user_id和item_id的特征,应该修改哪部份代码呢?
- [🐛BUG] Handling scores on training items when evaluating based on ranking
- [🐛BUG] recbole1.2.0与recbole-cdr兼容问题 HOT 2
- 尝试用General recommendation models进行个性化试题推荐发现效果不太好,求助 HOT 1
- 关于recbole中知识图谱数据集的问题请教 HOT 2
- run_hyper训练未完成 HOT 1
- [🐛BUG] Context-aware recommenders not properly embedding float sequences.
- 在训练的每一轮结束后释放显存缓冲区
- 想请问如何取出数据集的一部分进行训练?(小白)
- Context-aware DeepFM not learning HOT 2
- 我想请教一个ml-1m知识图谱数据集的配置信息问题 HOT 1
- 请问序列推荐时如何实现每一个时间步都进行预测
- [🐛BUG] Migration errors in SASRec
- 使用recbole1.2.0自动下载知识图谱数据集ml-1m时发生错误
- 使用recbole1.2.0时发现ml-1m的数据数量对不上
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recbole.