#NEWLINE# def test_binary_crossentropy( ) : #NEWLINE# #INDENT# from lasagne.objectives import binary_crossentropy #NEWLINE# ( p , t ) = theano . tensor . matrices ( 'pt' ) #NEWLINE# c = binary_crossentropy ( p , t ) #NEWLINE# floatX = theano . config . floatX #NEWLINE# predictions = np . random . rand ( 10 , 20 ) . astype ( floatX ) #NEWLINE# targets = np . random . rand ( 10 , 20 ) . astype ( floatX ) #NEWLINE# crossent = ( ( ( - targets ) * np . log ( predictions ) ) - ( ( 1 - targets ) * np . log ( ( 1 - predictions ) ) ) ) #NEWLINE# assert np . allclose ( crossent , c . eval ( { #NEWLINE# #INDENT# p : predictions , #NEWLINE# t : targets , #NEWLINE# #UNINDENT# } ) )