class_docstr: Visual Matrix Factorization.
  
  Parameters
  ----------
  k: int, optional, default: 10
      The dimension of the user and item factors.
      
  d: int, optional, default: 10
     The dimension of the user visual factors.
  
  n_epochs: int, optional, default: 100
      The number of epochs for SGD.
  
  learning_rate: float, optional, default: 0.001
      The learning rate for SGD_RMSProp.
  
  gamma: float, optional, default: 0.9
      The weight for previous/current gradient in RMSProp.
  
  lambda_u: float, optional, default: 0.001
      The regularization parameter for user factors.
  
  lambda_v: float, optional, default: 0.001
      The regularization parameter for item factors.
  
  lambda_p: float, optional, default: 1.0
      The regularization parameter for user visual factors.
  
  lambda_e: float, optional, default: 10.
      The regularization parameter for the kernel embedding matrix
      
  lambda_u: float, optional, default: 0.001
      The regularization parameter for user factors.
  
  name: string, optional, default: 'VMF'
      The name of the recommender model.
  
  trainable: boolean, optional, default: True
      When False, the model is not trained and Cornac assumes that the model is already         pre-trained (The parameters of the model U, V, P, E are not None).
      
  visual_features: See "cornac/examples/vmf_example.py" for an example of how to use         cornac's visual modality to load and provide the "item visual features" for VMF.
  
  verbose: boolean, optional, default: False
      When True, some running logs are displayed.
  
  init_params: dictionary, optional, default: None
      List of initial parameters, e.g., init_params = {'U':U, 'V':V, 'P': P, 'E': E}.
  
      U: numpy array of shape (n_users,k), user latent factors.
      V: numpy array of shape (n_items,k), item latent factors.
      P: numpy array of shape (n_users,d), user visual latent factors.
      E: numpy array of shape (d,c), embedding kernel matrix.
  
  seed: int, optional, default: None
      Random seed for parameters initialization.
  
  References
  ----------
  * Park, Chanyoung, Donghyun Kim, Jinoh Oh, and Hwanjo Yu. "Do Also-Viewed Products Help User Rating Prediction?."     In Proceedings of WWW, pp. 1113-1122. 2017.
class_docstr_tok: ["Visual","Matrix","Factorization",".","Parameters","--","--","--","--","--","k",":","int",",","optional",",","default",":","10","The","dimension","of","the","user","and","item","factors",".","d",":","int",",","optional",",","default",":","10","The","dimension","of","the","user","visual","factors",".","n_epochs",":","int",",","optional",",","default",":","100","The","number","of","epochs","for","SGD",".","learning_rate",":","float",",","optional",",","default",":","0.001","The","learning","rate","for","SGD_RMSProp",".","gamma",":","float",",","optional",",","default",":","0.9","The","weight","for","previous\/current","gradient","in","RMSProp",".","lambda_u",":","float",",","optional",",","default",":","0.001","The","regularization","parameter","for","user","factors",".","lambda_v",":","float",",","optional",",","default",":","0.001","The","regularization","parameter","for","item","factors",".","lambda_p",":","float",",","optional",",","default",":","1.0","The","regularization","parameter","for","user","visual","factors",".","lambda_e",":","float",",","optional",",","default",":","10",".","The","regularization","parameter","for","the","kernel","embedding","matrix","lambda_u",":","float",",","optional",",","default",":","0.001","The","regularization","parameter","for","user","factors",".","name",":","string",",","optional",",","default",":","'VMF'","The","name","of","the","recommender","model",".","trainable",":","boolean",",","optional",",","default",":","True","When","False",",","the","model","is","not","trained","and","Cornac","assumes","that","the","model","is","already","pre-trained","(","The","parameters","of","the","model","U",",","V",",","P",",","E","are","not","None",")",".","visual_features",":","See","``","cornac\/examples\/vmf_example.py","''","for","an","example","of","how","to","use","cornac","'s","visual","modality","to","load","and","provide","the","``","item","visual","features","''","for","VMF",".","verbose",":","boolean",",","optional",",","default",":","False","When","True",",","some","running","logs","are","displayed",".","init_params",":","dictionary",",","optional",",","default",":","None","List","of","initial","parameters",",","e.g.",",","init_params","=","{","'","U","'",":","U",",","'","V","'",":","V",",","'","P","'",":","P",",","'","E","'",":","E","}",".","U",":","numpy","array","of","shape","(","n_users",",","k",")",",","user","latent","factors",".","V",":","numpy","array","of","shape","(","n_items",",","k",")",",","item","latent","factors",".","P",":","numpy","array","of","shape","(","n_users",",","d",")",",","user","visual","latent","factors",".","E",":","numpy","array","of","shape","(","d",",","c",")",",","embedding","kernel","matrix",".","seed",":","int",",","optional",",","default",":","None","Random","seed","for","parameters","initialization",".","References","--","--","--","--","--","*","Park",",","Chanyoung",",","Donghyun","Kim",",","Jinoh","Oh",",","and","Hwanjo","Yu",".","``","Do","Also-Viewed","Products","Help","User","Rating","Prediction","?",".","''","In","Proceedings","of","WWW",",","pp",".","1113-1122",".","2017","."]
docstr: Fit the model to observations.
  
  Parameters
  ----------
  train_set: :obj:`cornac.data.Dataset`, required
      User-Item preference data as well as additional modalities.
  
  val_set: :obj:`cornac.data.Dataset`, optional, default: None
      User-Item preference data for model selection purposes (e.g., early stopping).
  
  Returns
  -------
  self : object
docstr_tok: ["Fit","the","model","to","observations",".","Parameters","--","--","--","--","--","train_set",":",":","obj",":","`","cornac.data.Dataset","`",",","required","User-Item","preference","data","as","well","as","additional","modalities",".","val_set",":",":","obj",":","`","cornac.data.Dataset","`",",","optional",",","default",":","None","User-Item","preference","data","for","model","selection","purposes","(","e.g.",",","early","stopping",")",".","Returns","--","--","--","-","self",":","object"]
code: def fit(self, train_set, val_set=None):
      """Fit the model to observations.
  
      Parameters
      ----------
      train_set: :obj:`cornac.data.Dataset`, required
          User-Item preference data as well as additional modalities.
  
      val_set: :obj:`cornac.data.Dataset`, optional, default: None
          User-Item preference data for model selection purposes (e.g., early stopping).
  
      Returns
      -------
      self : object
      """
  
      Recommender.fit(self, train_set, val_set)
  
      if self.trainable:
          # Item visual cnn-features
          item_features = train_set.item_image.features[
              : train_set.num_items
          ]
  
          if self.verbose:
              print("Learning...")
  
          from .vmf import vmf
  
          res = vmf(
              train_set,
              item_features,
              k=self.k,
              d=self.d,
              n_epochs=self.n_epochs,
              batch_size=self.batch_size,
              lambda_u=self.lambda_u,
              lambda_v=self.lambda_v,
              lambda_p=self.lambda_p,
              lambda_e=self.lambda_e,
              learning_rate=self.learning_rate,
              gamma=self.gamma,
              init_params={
                  "U": self.U,
                  "V": self.V,
                  "P": self.P,
                  "E": self.E,
              },
              use_gpu=self.use_gpu,
              verbose=self.verbose,
              seed=self.seed,
          )
  
          self.U = res["U"]
          self.V = res["V"]
          self.P = res["P"]
          self.E = res["E"]
          self.Q = res["Q"]
  
          if self.verbose:
              print("Learning completed")
  
      elif self.verbose:
          print(
              "%s is trained already (trainable = False)" % (self.name)
          )
  
      return self
  
file_path: cornac/cornac/models/vmf/recom_vmf.py
imports: import numpy
  from ..recommender import Recommender
  from ..recommender import ANNMixin, MEASURE_DOT
  from ...utils.common import sigmoid
  from ...utils.common import scale
  from ...exception import ScoreException
label_desc: Use image node_id 2 for calling the VMF obj's underlying member method code with example usage: obj.fit(train_set, val_set) and returns: self