Beispiel #1
0
 def infer(self,
           features=None,
           decode_length=1,
           beam_size=1,
           top_beams=1,
           alpha=0.0,
           use_tpu=False):
     """Predict."""
     features["targets"] = tf.identity(features["inputs"])
     logits, _ = self(features)
     log_probs = common_layers.log_prob_from_logits(logits)
     predictions, scores = common_layers.argmax_with_score(log_probs)
     return {
         "outputs": predictions,
         "scores": scores,
     }
Beispiel #2
0
 def infer(self,
           features=None,
           decode_length=1,
           beam_size=1,
           top_beams=1,
           alpha=0.0,
           use_tpu=False):
     """Predict."""
     del decode_length, beam_size, top_beams, alpha, use_tpu
     assert features is not None
     logits, _ = self(features)
     assert len(logits.get_shape()) == 5
     logits = tf.squeeze(logits, [1, 2, 3])
     log_probs = common_layers.log_prob_from_logits(logits)
     predictions, scores = common_layers.argmax_with_score(log_probs)
     return {
         "outputs": predictions,
         "scores": scores,
     }
Beispiel #3
0
 def infer(self,
           features=None,
           decode_length=50,
           beam_size=1,
           top_beams=1,
           alpha=0.0,
           use_tpu=False):
   """Predict."""
   del decode_length, beam_size, top_beams, alpha, use_tpu
   assert features is not None
   logits, _ = self(features)  # pylint: disable=not-callable
   assert len(logits.get_shape()) == 5
   logits = tf.squeeze(logits, [1, 2, 3])
   log_probs = common_layers.log_prob_from_logits(logits)
   predictions, scores = common_layers.argmax_with_score(log_probs)
   return {
       "outputs": predictions,
       "scores": scores,
   }