class_docstr: Caser Model
  
  :Citation:
  
      J. Tang and K. Wang, "Personalized top-n sequential recommendation via convolutional
      sequence embedding", in Proceedings of the Eleventh ACM International Conference on
      Web Search and Data Mining, ACM, 2018.
docstr: The main function to use CNN at both vertical and horizonal aspects.
  
  Args:
      hist_matrix (object): The output of history sequential embeddings
      vertical_dim (int): The shape of embeddings of input
      scope (object): The scope of CNN input.
  
  Returns:
      object: The output of CNN layers.
docstr_tok: ["The","main","function","to","use","CNN","at","both","vertical","and","horizonal","aspects",".","Args",":","hist_matrix","(","object",")",":","The","output","of","history","sequential","embeddings","vertical_dim","(","int",")",":","The","shape","of","embeddings","of","input","scope","(","object",")",":","The","scope","of","CNN","input",".","Returns",":","object",":","The","output","of","CNN","layers","."]
code: def _add_cnn(self, hist_matrix, vertical_dim, scope):
      """The main function to use CNN at both vertical and horizonal aspects.
  
      Args:
          hist_matrix (object): The output of history sequential embeddings
          vertical_dim (int): The shape of embeddings of input
          scope (object): The scope of CNN input.
  
      Returns:
          object: The output of CNN layers.
      """
      with tf.compat.v1.variable_scope(scope):
          with tf.compat.v1.variable_scope("vertical"):
              embedding_T = tf.transpose(a=hist_matrix, perm=[0, 2, 1])
              out_v = self._build_cnn(
                  embedding_T, self.n_v, vertical_dim
              )
              out_v = tf.compat.v1.layers.flatten(out_v)
          with tf.compat.v1.variable_scope("horizonal"):
              out_hs = []
              for h in self.lengths:
                  conv_out = self._build_cnn(hist_matrix, self.n_h, h)
                  max_pool_out = tf.reduce_max(
                      input_tensor=conv_out,
                      axis=[1],
                      name="max_pool_{0}".format(h),
                  )
                  out_hs.append(max_pool_out)
              out_h = tf.concat(out_hs, 1)
      return tf.concat([out_v, out_h], 1)
  
file_path: recommenders/recommenders/models/deeprec/models/sequential/caser.py
imports: import tensorflow
  from recommenders.models.deeprec.models.sequential.sequential_base_model import SequentialBaseModel
label_desc: Use image node_id 3 for calling the CaserModel obj's underlying member method code with example usage: obj._add_cnn(hist_matrix, vertical_dim, scope) and returns: tf