original_docstring: The main function to create NRMS's logic. The core of NRMS
          is a user encoder and a news encoder.
  
          Returns:
              object: a model used to train.
              object: a model used to evaluate and inference.
          
docstring: The main function to create NRMS's logic. The core of NRMS
  is a user encoder and a news encoder.
docstring_tokens: The main function to create NRMS ' s logic . The core of NRMS is a user encoder and a news encoder .
code: def _build_nrms(self):
          """The main function to create NRMS's logic. The core of NRMS
          is a user encoder and a news encoder.
  
          Returns:
              object: a model used to train.
              object: a model used to evaluate and inference.
          """
          hparams = self.hparams
  
          his_input_title = keras.Input(
              shape=(hparams.his_size, hparams.title_size), dtype="int32"
          )
          pred_input_title = keras.Input(
              shape=(hparams.npratio + 1, hparams.title_size), dtype="int32"
          )
          pred_input_title_one = keras.Input(
              shape=(
                  1,
                  hparams.title_size,
              ),
              dtype="int32",
          )
          pred_title_one_reshape = layers.Reshape((hparams.title_size,))(
              pred_input_title_one
          )
  
          embedding_layer = layers.Embedding(
              self.word2vec_embedding.shape[0],
              hparams.word_emb_dim,
              weights=[self.word2vec_embedding],
              trainable=True,
          )
  
          titleencoder = self._build_newsencoder(embedding_layer)
          self.userencoder = self._build_userencoder(titleencoder)
          self.newsencoder = titleencoder
  
          user_present = self.userencoder(his_input_title)
          news_present = layers.TimeDistributed(self.newsencoder)(pred_input_title)
          news_present_one = self.newsencoder(pred_title_one_reshape)
  
          preds = layers.Dot(axes=-1)([news_present, user_present])
          preds = layers.Activation(activation="softmax")(preds)
  
          pred_one = layers.Dot(axes=-1)([news_present_one, user_present])
          pred_one = layers.Activation(activation="sigmoid")(pred_one)
  
          model = keras.Model([his_input_title, pred_input_title], preds)
          scorer = keras.Model([his_input_title, pred_input_title_one], pred_one)
  
          return model, scorer
code_tokens: def _build_nrms ( self ) : hparams = self . hparams his_input_title = keras . Input ( shape = ( hparams . his_size , hparams . title_size ) , dtype = "int32" ) pred_input_title = keras . Input ( shape = ( hparams . npratio + 1 , hparams . title_size ) , dtype = "int32" ) pred_input_title_one = keras . Input ( shape = ( 1 , hparams . title_size , ) , dtype = "int32" , ) pred_title_one_reshape = layers . Reshape ( ( hparams . title_size , ) ) ( pred_input_title_one ) embedding_layer = layers . Embedding ( self . word2vec_embedding . shape [ 0 ] , hparams . word_emb_dim , weights = [ self . word2vec_embedding ] , trainable = True , ) titleencoder = self . _build_newsencoder ( embedding_layer ) self . userencoder = self . _build_userencoder ( titleencoder ) self . newsencoder = titleencoder user_present = self . userencoder ( his_input_title ) news_present = layers . TimeDistributed ( self . newsencoder ) ( pred_input_title ) news_present_one = self . newsencoder ( pred_title_one_reshape ) preds = layers . Dot ( axes = - 1 ) ( [ news_present , user_present ] ) preds = layers . Activation ( activation = "softmax" ) ( preds ) pred_one = layers . Dot ( axes = - 1 ) ( [ news_present_one , user_present ] ) pred_one = layers . Activation ( activation = "sigmoid" ) ( pred_one ) model = keras . Model ( [ his_input_title , pred_input_title ] , preds ) scorer = keras . Model ( [ his_input_title , pred_input_title_one ] , pred_one ) return model , scorer
short_docstring: The main function to create NRMS's logic.
short_docstring_tokens: The main function to create NRMS ' s logic .
comment: """The main function to create NRMS's logic. The core of NRMS
          is a user encoder and a news encoder.
  
          Returns:
              object: a model used to train.
              object: a model used to evaluate and inference.
          """