original_docstring: Compute the log loss of each element [batch_size, sequence_length]
docstring: Compute the log loss of each element [batch_size, sequence_length]
docstring_tokens: Compute the log loss of each element [ batch_size sequence_length ]
code: def _get_categorical_loss(self, categorical_sequences):
          """Compute the log loss of each element [batch_size, sequence_length]"""
  
          # Tensor shape: [batch_size, sequence_length, n_categories]
          target_indices = tf.cast(
              self.tensors.get_placeholder_by_name(
                  Features.categorical_features.name),
              tf.int32)
          target_indices_one_hot = tf.reshape(tf.one_hot(
              target_indices,
              axis=-1,
              depth=Constants.NUMBER_OF_CATEGORIES),
              [self.tensors.batch_size,
               Constants.INPUT_LENGTH,
               Constants.NUMBER_OF_CATEGORIES])
  
          # Tensor shape: [batch_size, sequence_length, n_categories]
          categorical_distributions = \
              self.mixture_density_builder.get_categorical_parameters(
                  categorical_sequences)
  
          # Tensor shape: [batch_size, sequence_length]
          categorical_loss = tf.reduce_sum(categorical_distributions *
                                           target_indices_one_hot,
                                           axis=-1)
          return -tf.log(categorical_loss)
code_tokens: def _get_categorical_loss ( self , categorical_sequences ) : target_indices = tf . cast ( self . tensors . get_placeholder_by_name ( Features . categorical_features . name ) , tf . int32 ) target_indices_one_hot = tf . reshape ( tf . one_hot ( target_indices , axis = - 1 , depth = Constants . NUMBER_OF_CATEGORIES ) , [ self . tensors . batch_size , Constants . INPUT_LENGTH , Constants . NUMBER_OF_CATEGORIES ] ) categorical_distributions = self . mixture_density_builder . get_categorical_parameters ( categorical_sequences ) categorical_loss = tf . reduce_sum ( categorical_distributions * target_indices_one_hot , axis = - 1 ) return - tf . log ( categorical_loss )
short_docstring: Compute the log loss of each element [batch_size, sequence_length]
short_docstring_tokens: Compute the log loss of each element [ batch_size sequence_length ]
comment: """Compute the log loss of each element [batch_size, sequence_length]"""$SEP$# Tensor shape: [batch_size, sequence_length, n_categories]$SEP$# Tensor shape: [batch_size, sequence_length, n_categories]$SEP$# Tensor shape: [batch_size, sequence_length]