#NEWLINE# def expr( self , model , data , **kwargs ) : #NEWLINE# #INDENT# '\n        Returns a theano expression for the cost function.\n\n        Returns a symbolic expression for a cost function applied to the\n        minibatch of data.\n        Optionally, may return None. This represents that the cost function\n        is intractable but may be optimized via the get_gradients method.\n\n        Parameters\n        ----------\n        model : a pylearn2 Model instance\n        data : a batch in cost.get_data_specs() form\n        kwargs : dict\n            Optional extra arguments. Not used by the base class.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# per_example = self . cost_per_example ( self , model , data , ** kwargs ) #NEWLINE# #UNINDENT# except NotImplementedError : #NEWLINE# #INDENT# raise NotImplementedError ( ( str ( type ( self ) ) + ' does not implement expr.' ) ) #NEWLINE# #UNINDENT# if ( per_example is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# assert ( per_example . ndim == 1 ) #NEWLINE# return per_example . mean ( )