-
Notifications
You must be signed in to change notification settings - Fork 46
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
模型中关于输入的feature_fields的疑惑 #2
Comments
这里的fields是为了生成offsets, 这里输入的数据经过label encode后,每一列是单独的label_encode, 而embedding的时候为了一次性的过一层embedding layer,就需要累加编码,比如A特征为0,1两种,B特征为0,1,2三种,那么需要把B的0,1,2变成2,3,4。这样在embedding中 A的0 和B的0不会被混淆关联issue |
我将您的代码跑通,取出一组数据,如下: |
嗯嗯, 的确,要累加,然后索引往后+1, 这里应该是个bug; 这里看上应该修改为fields = data_x.max().values + 1 |
Bug 所以,实际look up table中 故而在代码中 |
感谢解惑,还有一个问题,就是在Embedding的时候,torch.nn.Embedding(sum(feature_fields)+1,),这句代码是不是不用加1了? |
是的,可以不加 |
大佬,您好,您写的这个项目是我看到最优美的推荐代码,对于小白的我,非常受益,感谢您把您的工作分享出来,供大家学习。在阅读代码的时候,我一直有一个小小的疑惑,就是,fields = data_x.max().values,这句话的意思是获取到每列特征中最大的索引,比如第一列是0,1两个不同的特征,而这句代码直接就取到了1,然而实际就有两个不同的特征,这样做embedding的时候,每一列的特征都少一个,所以torch.nn.Embedding(sum(feature_fields)+1,1)是不是应该为torch.nn.Embedding(sum(feature_fields+1),1)?还有为什么要在sum(feature_fields)后面加个1呢?还请大佬明示,感谢!
The text was updated successfully, but these errors were encountered: