#NEWLINE# def categorical_crossentropy( output , target , from_logits = False ) : #NEWLINE# #INDENT# if from_logits : #NEWLINE# #INDENT# output = T . nnet . softmax ( output ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# output /= output . sum ( axis = ( - 1 ) , keepdims = True ) #NEWLINE# #UNINDENT# output = T . clip ( output , _EPSILON , ( 1.0 - _EPSILON ) ) #NEWLINE# return T . nnet . categorical_crossentropy ( output , target )