(values, padding_mask)
return tf.reduce_mean(values_per_ex)
Applies mask to values then returns overall average (a scalar)

  Args:
    values: a list length max_dec_steps containing arrays shape (batch_size).
    padding_mask: tensor shape (batch_size, max_dec_steps) containing 1s and 0s.

  Returns:
    a scalar
Applies mask to values then returns overall average (a scalar)
Applies mask to values then returns overall average ( a scalar )
def _mask_and_avg(values, padding_mask):
  """Applies mask to values then returns overall average (a scalar)

  Args:
    values: a list length max_dec_steps containing arrays shape (batch_size).
    padding_mask: tensor shape (batch_size, max_dec_steps) containing 1s and 0s.

  Returns:
    a scalar
  """

  dec_lens = tf.reduce_sum(padding_mask, axis=1) # shape batch_size. float32
  values_per_step = [v * padding_mask[:,dec_step] for dec_step,v in enumerate(values)]
  values_per_ex = sum(values_per_step)/dec_lens # shape (batch_size); normalized value for each batch member
  return tf.reduce_mean(values_per_ex)
def _mask_and_avg ( values , padding_mask ) : dec_lens = tf . reduce_sum ( padding_mask , axis = 1 ) # shape batch_size. float32 values_per_step = [ v * padding_mask [ : , dec_step ] for dec_step , v in enumerate ( values ) ] values_per_ex = sum ( values_per_step ) / dec_lens # shape (batch_size); normalized value for each batch member return tf . reduce_mean ( values_per_ex )