parameters: (self, times, values, mode)
docstring: Add regularization during training.
docstring_summary: Add regularization during training.
docstring_tokens: Add regularization during training .
function: def _loss_additions(self, times, values, mode):
      """Add regularization during training."""
      if mode == estimator_lib.ModeKeys.TRAIN:
        if (self._input_statistics is not None
            and self._configuration.bayesian_prior_weighting):
          normalization = 1. / math_ops.cast(
              self._input_statistics.total_observation_count, self.dtype)
        else:
          # If there is no total observation count recorded, or if we are not
          # doing a Bayesian prior weighting, assumes/pretends that the full
          # dataset size is the window size.
          normalization = 1. / math_ops.cast(
              array_ops.shape(times)[1], self.dtype)
        transition_contribution = ops.convert_to_tensor(
            self._configuration.covariance_prior_fn(
                self.state_transition_noise_covariance),
            dtype=self.dtype)
        if (self._configuration.use_observation_noise
            and self._observation_noise_covariance is not None):
          observation_contribution = ops.convert_to_tensor(
              self._configuration.covariance_prior_fn(
                  self._observation_noise_covariance),
              dtype=self.dtype)
          regularization_sum = transition_contribution + observation_contribution
        else:
          regularization_sum = transition_contribution
        return -normalization * regularization_sum
      else:
        return array_ops.zeros([], dtype=self.dtype)
function_tokens: def _loss_additions ( self , times , values , mode ) : if mode == estimator_lib . ModeKeys . TRAIN : if ( self . _input_statistics is not None and self . _configuration . bayesian_prior_weighting ) : normalization = 1. / math_ops . cast ( self . _input_statistics . total_observation_count , self . dtype ) else : # If there is no total observation count recorded, or if we are not # doing a Bayesian prior weighting, assumes/pretends that the full # dataset size is the window size. normalization = 1. / math_ops . cast ( array_ops . shape ( times ) [ 1 ] , self . dtype ) transition_contribution = ops . convert_to_tensor ( self . _configuration . covariance_prior_fn ( self . state_transition_noise_covariance ) , dtype = self . dtype ) if ( self . _configuration . use_observation_noise and self . _observation_noise_covariance is not None ) : observation_contribution = ops . convert_to_tensor ( self . _configuration . covariance_prior_fn ( self . _observation_noise_covariance ) , dtype = self . dtype ) regularization_sum = transition_contribution + observation_contribution else : regularization_sum = transition_contribution return - normalization * regularization_sum else : return array_ops . zeros ( [ ] , dtype = self . dtype )