def __init__(self, feature_cards, factor_dim, hidden_sizes, dropout_rate=.1, name='fnfm'):
     super(FieldAwareNeuralFactorizationMachine, self).__init__(name=name)
     self.num_features = len(feature_cards)
     self.embeddings = FieldAwareEmbedFeatures(feature_cards, factor_dim,
                                               name=name + '/field_aware_feature_embedding')
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
     self.nn = FullyConnectedNetwork(units=hidden_sizes, dropout_rate=dropout_rate, name=name + '/fcn')
Exemplo n.º 2
0
 def __init__(self, feature_cards, factor_dim, name='ffm'):
     super(FieldAwareFactorizationMachine, self).__init__(name=name)
     self.factor_dim = factor_dim
     self.embeddings = FieldAwareEmbedFeatures(
         feature_cards,
         factor_dim,
         name=name + '/field_aware_feature_embeddings')
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
Exemplo n.º 3
0
 def __init__(self,
              feature_cards,
              factor_dim,
              name='factorization_machine'):
     super(FactorizationMachine, self).__init__(name=name)
     self.embedding = EmbedFeatures(feature_cards,
                                    factor_dim,
                                    name=name + '/feature_embedding')
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
Exemplo n.º 4
0
 def __init__(self, feature_cards, factor_dim, n_heads, n_attentions, hidden_sizes, dropout_rate=.1, name='deepfm'):
     super(AutomaticFeatureInteraction, self).__init__(name=name)
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
     self.embedding = EmbedFeatures(feature_cards, factor_dim, name=name + '/feature_embedding')
     self.flatten = tf.keras.layers.Flatten(data_format='channels_first')
     self.nn = FullyConnectedNetwork(units=hidden_sizes, dropout_rate=dropout_rate, name=name + '/fcn')
     self.attns = [
         MultiHeadAttention(n_heads, factor_dim, dropout_rate=dropout_rate, name=name + '/mhattn{}'.format(i))
         for i in range(n_attentions)
     ]
     self.attn_out = tf.keras.layers.Dense(1)
Exemplo n.º 5
0
 def __init__(self, feature_cards, factor_dim, attention_size, name='afm'):
     super(AttentionalFactorizationMachine, self).__init__(name=name)
     self.num_features = len(feature_cards)
     self.factor_dim = factor_dim
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
     self.embedding = EmbedFeatures(feature_cards, factor_dim, name=name + '/feature_embedding')
     self.attention = tf.keras.Sequential([
         tf.keras.layers.Dense(units=attention_size, name=name + '/attention_hidden'),
         tf.keras.layers.ReLU(name=name + '/attention_activ'),
         tf.keras.layers.Dense(units=1, name=name + '/attention_logits'),
         tf.keras.layers.Softmax(axis=1, name=name + '/attention_score')
     ])
Exemplo n.º 6
0
 def __init__(self,
              feature_cards,
              factor_dim,
              hidden_sizes,
              dropout_rate=.1,
              name='neural_factorization_machine'):
     super(NeuralFactorizationMachine, self).__init__(name=name)
     self.embedding = EmbedFeatures(feature_cards,
                                    factor_dim,
                                    name=name + '/feature_embedding')
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
     self.nn = FullyConnectedNetwork(units=hidden_sizes,
                                     dropout_rate=dropout_rate,
                                     name=name + '/fcn')
Exemplo n.º 7
0
 def __init__(self,
              feature_cards,
              factor_dim,
              hidden_sizes,
              dropout_rate=.1,
              name='deepfm'):
     super(DeepFM, self).__init__(name=name)
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
     self.embedding = EmbedFeatures(feature_cards,
                                    factor_dim,
                                    name=name + '/feature_embedding')
     self.flatten = tf.keras.layers.Flatten(data_format='channels_first')
     self.nn = FullyConnectedNetwork(units=hidden_sizes,
                                     dropout_rate=dropout_rate,
                                     name=name + '/fcn')
Exemplo n.º 8
0
 def __init__(self,
              feature_cards,
              factor_dim,
              fnn_hidden_sizes,
              cin_hidden_sizes,
              dropout_rate=.1,
              split=True,
              name='xdeepfm'):
     super(ExtremeDeepFactorizationMachine, self).__init__(name=name)
     self.linear = LinearModel(feature_cards, name=name + '/linear_model')
     self.embedding = EmbedFeatures(feature_cards,
                                    factor_dim,
                                    name=name + '/feature_embedding')
     self.flatten = tf.keras.layers.Flatten(data_format='channels_first')
     self.nn = FullyConnectedNetwork(units=fnn_hidden_sizes,
                                     dropout_rate=dropout_rate,
                                     name=name + '/fcn')
     self.cin = CompressedInteractionNetwork(cin_hidden_sizes,
                                             split,
                                             name=name + '/cin')