class_docstr: Categorical probability distribution
docstr: return tf.nn.sparse_softmax_cross_entropy_with_logits(logits=self.logits, labels=x)
  Note: we can't use sparse_softmax_cross_entropy_with_logits because
        the implementation does not allow second-order derivatives...
docstr_tok: ["return","tf.nn.sparse_softmax_cross_entropy_with_logits","(","logits=self.logits",",","labels=x",")","Note",":","we","ca","n't","use","sparse_softmax_cross_entropy_with_logits","because","the","implementation","does","not","allow","second-order","derivatives","..."]
code: def neglogp(self, x):
      """
      return tf.nn.sparse_softmax_cross_entropy_with_logits(logits=self.logits, labels=x)
      Note: we can't use sparse_softmax_cross_entropy_with_logits because
            the implementation does not allow second-order derivatives...
      """
      if x.dtype in {tf.uint8, tf.int32, tf.int64}:
          # one-hot encoding
          x_shape_list = x.shape.as_list()
          logits_shape_list = self.logits.get_shape().as_list()[:-1]
          for xs, ls in zip(x_shape_list, logits_shape_list):
              if xs is not None and ls is not None:
                  assert (
                      xs == ls
                  ), "shape mismatch: {} in x vs {} in logits".format(
                      xs, ls
                  )
  
          x = tf.one_hot(x, self.logits.get_shape().as_list()[-1])
      else:
          # already encoded
          assert x.shape.as_list() == self.logits.shape.as_list()
  
      return tf.nn.softmax_cross_entropy_with_logits_v2(
          logits=self.logits, labels=x
      )
  
imports: import tensorflow.compat.v1
  from .util import fc
label_desc: Use image node_id 5 for calling the CategoricalPd obj's underlying member method code with example usage: obj.neglogp(x) and returns: tf