def expr(self, model, data, ** kwargs):

        # Fall back to cost_per_example implementation if possible
        try:
            per_example = self.cost_per_example(self, model, data, **kwargs)
        except NotImplementedError:
            raise NotImplementedError(str(type(self)) + " does not implement "
                                      "expr.")

        # Handle explicitly undefined costs
        if per_example is None:
            return None

        assert per_example.ndim == 1

        return per_example.mean()
Returns a theano expression for the cost function.
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/costs/cost.py/Cost.expr