# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/models/tf/deepmf.ipynb (unless otherwise specified).

__all__ = ['DeepMF']

# Cell
import tensorflow as tf
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Embedding, Flatten, Input, Dot


class DeepMF:
    """Deep Matrix Factorization.
    """
    def __init__(self, num_users, num_items, latent_dim=20):
        self.num_users = num_users
        self.num_items = num_items
        self.latent_dim = latent_dim

    def build(self):
        user_input = Input(shape=[1])
        user_embedding = Embedding(self.num_users, self.latent_dim)(user_input)
        user_vec = Flatten()(user_embedding)

        item_input = Input(shape=[1])
        item_embedding = Embedding(self.num_items, self.latent_dim)(item_input)
        item_vec = Flatten()(item_embedding)

        dot = Dot(axes=1)([item_vec, user_vec])

        model = Model([user_input, item_input], dot)
        return model