code: def test_categorical_crossentropy_onehot():
      # symbolic version
      from lasagne.objectives import categorical_crossentropy
  
      p = theano.tensor.matrix("p")
      t = theano.tensor.ivector("t")  # correct class per item
      c = categorical_crossentropy(p, t)
      # numeric version
      floatX = theano.config.floatX
      predictions = np.random.rand(10, 20).astype(floatX)
      predictions /= predictions.sum(axis=1, keepdims=True)
      targets = np.random.randint(20, size=10).astype(np.uint8)
      crossent = -np.log(predictions[np.arange(10), targets])
      # compare
      assert np.allclose(crossent, c.eval({p: predictions, t: targets}))
  
imports: import numpy
  import theano
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: test_categorical_crossentropy_onehot() without return types