original_docstring: Matching loss for a sigmoid activation function.
docstring: Matching loss for a sigmoid activation function.
docstring_tokens: Matching loss for a sigmoid activation function .
code: def cross_entropy(y, y_hat):
      '''Matching loss for a sigmoid activation function.'''
      y = tf.convert_to_tensor(y)
      y_hat = tf.convert_to_tensor(y_hat)
      positive_cross_entropy_terms = tf.where(
          tf.greater(y, 0.0), y * tf.log(y_hat), tf.zeros_like(y))
      negative_cross_entropy_terms = tf.where(
          tf.less(y, 1.0), (1.0 - y) * tf.log(1.0 - y_hat), tf.zeros_like(y))
      return -tf.reduce_sum(
          positive_cross_entropy_terms + negative_cross_entropy_terms, axis=1)
code_tokens: def cross_entropy ( y , y_hat ) : y = tf . convert_to_tensor ( y ) y_hat = tf . convert_to_tensor ( y_hat ) positive_cross_entropy_terms = tf . where ( tf . greater ( y , 0.0 ) , y * tf . log ( y_hat ) , tf . zeros_like ( y ) ) negative_cross_entropy_terms = tf . where ( tf . less ( y , 1.0 ) , ( 1.0 - y ) * tf . log ( 1.0 - y_hat ) , tf . zeros_like ( y ) ) return - tf . reduce_sum ( positive_cross_entropy_terms + negative_cross_entropy_terms , axis = 1 )
short_docstring: Matching loss for a sigmoid activation function.
short_docstring_tokens: Matching loss for a sigmoid activation function .
comment: '''Matching loss for a sigmoid activation function.'''