#NEWLINE# def test_batch_norm( self ) : #NEWLINE# #INDENT# import theano , numpy #NEWLINE# def batchnorm( W , b , data ) : #NEWLINE# #INDENT# return numpy . asarray ( ( ( W * ( ( data - numpy . mean ( data ) ) / numpy . std ( data ) ) ) + b ) , dtype = theano . config . floatX ) #NEWLINE# #UNINDENT# data = numpy . random . randn ( 1 , 100 ) . astype ( theano . config . floatX ) #NEWLINE# inp = ML . Input ( 100 , 'inp' ) #NEWLINE# bn = ML . BatchNormalization ( ) #NEWLINE# model = ( inp > bn ) #NEWLINE# m1 = numpy . mean ( model . propagate ( bn , inp = data ) ) #NEWLINE# m2 = numpy . mean ( batchnorm ( bn . getW ( ) , bn . getb ( ) , data ) ) #NEWLINE# epsilon = 1e-06 #NEWLINE# self . assertTrue ( ( ( m1 - m2 ) < epsilon ) )