CTR_Algorithm icon indicating copy to clipboard operation
CTR_Algorithm copied to clipboard

关于DIN模型的疑惑

Open yanduoduan opened this issue 3 years ago • 4 comments

大佬您好,最近看您的DIN代码,有一些地方不太明白,希望得到您的解答! 1、mask = (behaviors_x > 0).float().unsqueeze(-1) 这里的msak的具体作用是啥啊?为什么需要这个mask呢? 这里的 注意力输入部分,原始的好像没有queries - user_behavior吧?为啥有这一项呢 2、attn_input = torch.cat([queries, user_behavior, queries - user_behavior, queries * user_behavior], dim = -1) 3、 output = user_behavior.mul(attns.mul(mask)) # batch * seq_len * embed_dim 这个里面为啥还有mask呢?

yanduoduan avatar Apr 06 '22 01:04 yanduoduan

因为行为序列是不固定长度的,为了方便处理,给它固定长度了,比如20个行为,那没有20个行为的会用0 padding到20。在实际计算的时候padding这部分是不参与计算loss的,这就是mask的作用。

发自我的iPhone

在 2022年4月6日,09:15,yanduoduan @.***> 写道:



大佬您好,最近看您的DIN代码,有一些地方不太明白,希望得到您的解答! 1、mask = (behaviors_x > 0).float().unsqueeze(-1) 这里的msak的具体作用是啥啊?为什么需要这个mask呢? 这里的 注意力输入部分,原始的好像没有queries - user_behavior吧?为啥有这一项呢 2、attn_input = torch.cat([queries, user_behavior, queries - user_behavior, queries * user_behavior], dim = -1) 3、 output = user_behavior.mul(attns.mul(mask)) # batch * seq_len * embed_dim 这个里面为啥还有mask呢?

— Reply to this email directly, view it on GitHubhttps://github.com/Prayforhanluo/CTR_Algorithm/issues/5, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE6TMLMKN2GFHVIZLCFBDQDVDTQTDANCNFSM5SUOIMLA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Prayforhanluo avatar Apr 06 '22 01:04 Prayforhanluo

queries - user_behavior我记得它源码里有,好像,就加上了。

发自我的iPhone

在 2022年4月6日,09:37,罗 瀚 @.***> 写道:

 因为行为序列是不固定长度的,为了方便处理,给它固定长度了,比如20个行为,那没有20个行为的会用0 padding到20。在实际计算的时候padding这部分是不参与计算loss的,这就是mask的作用。

发自我的iPhone

在 2022年4月6日,09:15,yanduoduan @.***> 写道:



大佬您好,最近看您的DIN代码,有一些地方不太明白,希望得到您的解答! 1、mask = (behaviors_x > 0).float().unsqueeze(-1) 这里的msak的具体作用是啥啊?为什么需要这个mask呢? 这里的 注意力输入部分,原始的好像没有queries - user_behavior吧?为啥有这一项呢 2、attn_input = torch.cat([queries, user_behavior, queries - user_behavior, queries * user_behavior], dim = -1) 3、 output = user_behavior.mul(attns.mul(mask)) # batch * seq_len * embed_dim 这个里面为啥还有mask呢?

— Reply to this email directly, view it on GitHubhttps://github.com/Prayforhanluo/CTR_Algorithm/issues/5, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE6TMLMKN2GFHVIZLCFBDQDVDTQTDANCNFSM5SUOIMLA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Prayforhanluo avatar Apr 06 '22 01:04 Prayforhanluo

queries - user_behavior,看DIN模型图上,只有一个out Product 和其余的两个输入concat,没看到两个相减啊。

yanduoduan avatar Apr 06 '22 06:04 yanduoduan

DIN的开源代码是有的

https://github.com/zhougr1993/DeepInterestNetwork/blob/master/din/model.py

第209行

Prayforhanluo avatar Apr 06 '22 14:04 Prayforhanluo