#NEWLINE# def test_binary_hinge_loss( ) : #NEWLINE# #INDENT# from lasagne.objectives import binary_hinge_loss #NEWLINE# from lasagne.nonlinearities import rectify #NEWLINE# p = theano . tensor . vector ( 'p' ) #NEWLINE# t = theano . tensor . ivector ( 't' ) #NEWLINE# c = binary_hinge_loss ( p , t ) #NEWLINE# floatX = theano . config . floatX #NEWLINE# predictions = np . random . rand ( 10 ) . astype ( floatX ) #NEWLINE# targets = np . random . random_integers ( 0 , 1 , ( 10 , ) ) . astype ( 'int8' ) #NEWLINE# hinge = rectify ( ( 1 - ( predictions * ( ( 2 * targets ) - 1 ) ) ) ) #NEWLINE# assert np . allclose ( hinge , c . eval ( { #NEWLINE# #INDENT# p : predictions , #NEWLINE# t : targets , #NEWLINE# #UNINDENT# } ) )