wujcan/SGL-Torch

跑iFashion数据集时会报错 error occurs when I try to train on the dataset of iFsahion

Closed this issue · 8 comments

跑yelp2018和amazon-book都是正常的,不同层都取得了论文中的效果,但跑iFashion数据集时遇到了如下错误
image
我目前的代码能力太弱了,不知道是为什么,希望能够获得解答,万分感谢!

I have same issue with other dataset also.... Finding the solutions

wujcan commented

这个问题应该是没有对user和item的id进行remap导致的,可以参考TensorFlow版本的代码对数据集重新remap id。

这个问题应该是没有对user和item的id进行remap导致的,可以参考TensorFlow版本的代码对数据集重新remap id。

抱歉,我的代码能力比较弱,请问在您的pytorch版本代码上应该如何进行改动呢?

这个问题应该是没有对user和item的id进行remap导致的,可以参考TensorFlow版本的代码对数据集重新remap id。

由于高版本CUDA与低版本Tensorflow的不兼容,我只能用SGL-Torch版本去复现。我用SGL-Tensorflow代码生成了重新remap的数据文件,再将其输入到SGL-Torch版本,但是还是会报一样的错误。请问这是什么问题导致的?谢谢!

我也遇见了同样的问题,我是通过将数据集中item为1或者为0的user删去解决的,其实我筛选了item数目10以上的user

将data\sampler.py中第123行至133行代码
for user, pos_len in user_pos_len.items():
try:
pos_items = user_pos_dict[user]
pos_idx = randint_choice(len(pos_items), size=pos_len, replace=True)
pos_idx = pos_idx if isinstance(pos_idx, Iterable) else [pos_idx]
user_pos_sample[user] = list(pos_items[pos_idx])

        neg_items = randint_choice(num_item, size=pos_len, replace=True, exclusion=user_pos_dict[user])
        user_neg_sample[user] = neg_items if isinstance(neg_items, Iterable) else [neg_items]
    except:
        print('error')

替换成
for user, pos_len in user_pos_len.items():
pos_items = user_pos_dict[user]
user_pos_sample[user] = list(np.random.choice(pos_items, size=pos_len, replace=True))

    user_neg_sample[user] = list(np.random.choice(num_item, size=pos_len, replace=True, p=None))

即可。
因为源代码中使用的索引取值方法,当item数目为1的时候,会出现报错,因此直接替换成随机取值方法即可。