@wraps(Cost.expr)
    def expr(self, model, data, ** kwargs):
        self.get_data_specs(model)[0].validate(data)
        X = data
        # X is theano sparse
        X_dense = theano.sparse.dense_from_sparse(X)
        noise = self.random_stream.binomial(size=X_dense.shape, n=1,
                                            prob=self.one_ratio, ndim=None)

        # a random pattern that indicates to reconstruct all the 1s and some of
        # the 0s in X
        P = noise + X_dense
        P = theano.tensor.switch(P > 0, 1, 0)
        P = tensor.cast(P, theano.config.floatX)

        # L1 penalty on activations
        reg_units = theano.tensor.abs_(model.encode(X)).sum(axis=1).mean()

        # penalty on weights, optional
        # params = model.get_params()
        # W = params[2]

        # there is a numerical problem when using
        # tensor.log(1 - model.reconstruct(X, P))
        # Pascal fixed it.
        before_activation = model.reconstruct_without_dec_acti(X, P)

        cost = (1 * X_dense *
                tensor.log(tensor.log(1 + tensor.exp(-1 * before_activation)))
                / (1 - X_dense) *
                tensor.log(1 + tensor.log(1 + tensor.exp(before_activation))))

        cost = (cost * P).sum(axis=1).mean()

        cost = cost + self.L1 * reg_units

        return cost
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/costs/autoencoder.py/SampledMeanBinaryCrossEntropy.expr/operator `+` -> `/`