赞
踩
1:BPR
BPR: Bayesian Personalized Ranking from Implicit Feedback.
BPR is a basic matrix factorization model that be trained in the pairwise way.
定义各个层和损失
对user进行embedding
self.user_embedding = nn.Embedding(self.n_users, self.embedding_size)
对item进行embedding
self.item_embedding = nn.Embedding(self.n_items, self.embedding_size)
损失定义
self.loss = BPRLoss()
2:xDeepFM
xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems.
xDeepFM combines a CIN (Compressed Interaction Network) with a classical DNN.The model is able to learn certain bounded-degree feature interactions explicitly; Besides, it can also learn arbitrary low- and high-order feature interactions implicitly.
构建CIN模块,CIN结合了RNN和CNN的思想,一共构建三层。
第一个卷积层
conv1d = nn.Conv1d(self.field_nums[-1] * self.field_nums[0], layer_size, 1).to(self.device)
在Conv1d()函数中需要传入输入通道,输出通道,以及卷积核。在第一个Conv1d中8*8=64通道,输出为100通道。
第一个卷积层
conv1d = nn.Conv1d(self.field_nums[-1] * self.field_nums[0], layer_size, 1).to(self.device)
在第二个Conv1d中50*8=400通道,输出为100通道。
conv1d = nn.Conv1d(self.field_nums[-1] * self.field_nums[0], layer_size, 1).to(self.device)
在第三个Conv1d中50*8=400通道,输出为100通道。
定义MPL层一共三个循环:每个循环进行Dropout,Linear,activation。
mlp_modules.append(nn.Dropout(p=self.dropout))
mlp_modules.append(nn.Linear(input_size, output_size))
activation_func = activation_layer
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。