class_docstr: Neural Collaborative Filtering (NCF) implementation
  
  :Citation:
  
      He, Xiangnan, Lizi Liao, Hanwang Zhang, Liqiang Nie, Xia Hu, and Tat-Seng Chua. "Neural collaborative filtering."
      In Proceedings of the 26th International Conference on World Wide Web, pp. 173-182. International World Wide Web
      Conferences Steering Committee, 2017. Link: https://www.comp.nus.edu.sg/~xiangnan/papers/ncf.pdf
class_docstr_tok: ["Neural","Collaborative","Filtering","(","NCF",")","implementation",":","Citation",":","He",",","Xiangnan",",","Lizi","Liao",",","Hanwang","Zhang",",","Liqiang","Nie",",","Xia","Hu",",","and","Tat-Seng","Chua",".","``","Neural","collaborative","filtering",".","''","In","Proceedings","of","the","26th","International","Conference","on","World","Wide","Web",",","pp",".","173-182.","International","World","Wide","Web","Conferences","Steering","Committee",",","2017",".","Link",":","https",":","\/\/www.comp.nus.edu.sg\/~xiangnan\/papers\/ncf.pdf"]
docstr: Constructor
  
  Args:
      n_users (int): Number of users in the dataset.
      n_items (int): Number of items in the dataset.
      model_type (str): Model type.
      n_factors (int): Dimension of latent space.
      layer_sizes (list): Number of layers for MLP.
      n_epochs (int): Number of epochs for training.
      batch_size (int): Batch size.
      learning_rate (float): Learning rate.
      verbose (int): Whether to show the training output or not.
      seed (int): Seed.
docstr_tok: ["Constructor","Args",":","n_users","(","int",")",":","Number","of","users","in","the","dataset",".","n_items","(","int",")",":","Number","of","items","in","the","dataset",".","model_type","(","str",")",":","Model","type",".","n_factors","(","int",")",":","Dimension","of","latent","space",".","layer_sizes","(","list",")",":","Number","of","layers","for","MLP",".","n_epochs","(","int",")",":","Number","of","epochs","for","training",".","batch_size","(","int",")",":","Batch","size",".","learning_rate","(","float",")",":","Learning","rate",".","verbose","(","int",")",":","Whether","to","show","the","training","output","or","not",".","seed","(","int",")",":","Seed","."]
code: def __init__(
      self,
      n_users,
      n_items,
      model_type="NeuMF",
      n_factors=8,
      layer_sizes=[16, 8, 4],
      n_epochs=50,
      batch_size=64,
      learning_rate=5e-3,
      verbose=1,
      seed=None,
  ):
      """Constructor
  
      Args:
          n_users (int): Number of users in the dataset.
          n_items (int): Number of items in the dataset.
          model_type (str): Model type.
          n_factors (int): Dimension of latent space.
          layer_sizes (list): Number of layers for MLP.
          n_epochs (int): Number of epochs for training.
          batch_size (int): Batch size.
          learning_rate (float): Learning rate.
          verbose (int): Whether to show the training output or not.
          seed (int): Seed.
  
      """
  
      # seed
      tf.compat.v1.set_random_seed(seed)
      np.random.seed(seed)
      self.seed = seed
  
      self.n_users = n_users
      self.n_items = n_items
      self.model_type = model_type.lower()
      self.n_factors = n_factors
      self.layer_sizes = layer_sizes
      self.n_epochs = n_epochs
      self.verbose = verbose
      self.batch_size = batch_size
      self.learning_rate = learning_rate
  
      # check model type
      model_options = ["gmf", "mlp", "neumf"]
      if self.model_type not in model_options:
          raise ValueError(
              "Wrong model type, please select one of this list: {}".format(
                  model_options
              )
          )
  
      # ncf layer input size
      self.ncf_layer_size = n_factors + layer_sizes[-1]
      # create ncf model
      self._create_model()
      # set GPU use with demand growth
      gpu_options = tf.compat.v1.GPUOptions(allow_growth=True)
      # set TF Session
      self.sess = tf.compat.v1.Session(
          config=tf.compat.v1.ConfigProto(gpu_options=gpu_options)
      )
      # parameters initialization
      self.sess.run(tf.compat.v1.global_variables_initializer())
  
file_path: recommenders/recommenders/models/ncf/ncf_singlenode.py
imports: import os
  import numpy
  import tensorflow
  import tf_slim
  from time import time
  import logging
label_desc: Use image node_id 1 to create a new NCF object  with example: obj = NCF(n_users, n_items, model_type, n_factors, layer_sizes, n_epochs, batch_size, learning_rate, verbose, seed)