Skip to content

Instantly share code, notes, and snippets.

View khanhnamle1994's full-sized avatar
🎯
Focusing

James Le khanhnamle1994

🎯
Focusing
View GitHub Profile
@khanhnamle1994
khanhnamle1994 / NeuralFM.py
Created April 23, 2020 12:45
Neural Factorization Machine model
import torch
from layer import FactorizationMachine, FeaturesEmbedding, MultiLayerPerceptron, FeaturesLinear
class NeuralFactorizationMachineModel(torch.nn.Module):
"""
A Pytorch implementation of Neural Factorization Machine.
Reference:
X He and TS Chua, Neural Factorization Machines for Sparse Predictive Analytics, 2017.
@khanhnamle1994
khanhnamle1994 / xDeepFM.py
Created April 23, 2020 12:44
Extreme Deep Factorization Machine model
import torch
from layer import CompressedInteractionNetwork, FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron
class ExtremeDeepFactorizationMachineModel(torch.nn.Module):
"""
A Pytorch implementation of xDeepFM.
Reference:
J Lian, et al. xDeepFM: Combining Explicit and Implicit Feature Interactions for Recommender Systems, 2018.
@khanhnamle1994
khanhnamle1994 / DeepFM.py
Created April 23, 2020 12:43
Deep Factorization Machine model
import torch
from layer import FactorizationMachine, FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron
class DeepFactorizationMachineModel(torch.nn.Module):
"""
A Pytorch implementation of DeepFM.
Reference:
H Guo, et al. DeepFM: A Factorization-Machine based Neural Network for CTR Prediction, 2017.
@khanhnamle1994
khanhnamle1994 / Wide_Deep.py
Created April 23, 2020 12:41
Wide and Deep Learning model
import torch
from layer import FeaturesLinear, FeaturesEmbedding, MultiLayerPerceptron
class WideAndDeepModel(torch.nn.Module):
"""
A Pytorch implementation of wide and deep learning.
Reference:
HT Cheng, et al. Wide & Deep Learning for Recommender Systems, 2016.
@khanhnamle1994
khanhnamle1994 / MF.py
Created February 22, 2020 22:16
Matrix Factorization class
import torch
from torch import nn
import torch.nn.functional as F
class MF(nn.Module):
def __call__(self, train_x):
# These are the user indices, and correspond to "u" variable
user_id = train_x[:, 0]
@khanhnamle1994
khanhnamle1994 / MFBiases.py
Created February 22, 2020 22:15
Matrix Factorization with Biases class
import torch
from torch import nn
import torch.nn.functional as F
class MF(nn.Module):
def __call__(self, train_x):
# These are the user indices, and correspond to "u" variable
user_id = train_x[:, 0]
@khanhnamle1994
khanhnamle1994 / MFSideFeat.py
Created February 22, 2020 22:12
Matrix Factorization with Side Features class
import torch
from torch import nn
import torch.nn.functional as F
class MF(nn.Module):
def __call__(self, train_x):
# These are the user indices, and correspond to "u" variable
user_id = train_x[:, 0]
@khanhnamle1994
khanhnamle1994 / MFTemporalFeat.py
Created February 22, 2020 22:08
Matrix Factorization with Temporal Features class
import torch
from torch import nn
import torch.nn.functional as F
class MF(nn.Module):
def __call__(self, train_x):
# These are the user indices, and correspond to "u" variable
user_id = train_x[:, 0]
@khanhnamle1994
khanhnamle1994 / FM.py
Created February 22, 2020 22:06
Factorization Machines class
import torch
from torch import nn
import torch.nn.functional as F
class MF(nn.Module):
def __call__(self, train_x):
# Pull out biases
biases = index_into(self.bias_feat.weight, train_x).squeeze().sum(dim=1)
@khanhnamle1994
khanhnamle1994 / MFMixTaste.py
Created February 22, 2020 22:03
Matrix Factorization with Mixture of Tastes class
import torch
from torch import nn
import torch.nn.functional as F
class MF(nn.Module):
def __call__(self, train_x):
# These are the user and item indices
user_id = train_x[:, 0]