On 2013-01-24 2:07 PM, "Gael Varoquaux" <notifications@github.com> wrote:
>
> In sklearn/neural_networks/rbm.py:
>
> > +        Computes the free energy
> > +        ``\mathcal{F}({\bf v}) = - \log \sum_{\bf h} e^{-E({\bf
v},{\bf h})}``.
> > +
> > +        Parameters
> > +        ----------
> > +        v: array-like, shape (n_samples, n_features)
> > +
> > +        Returns
> > +        -------
> > +        free_energy: array-like, shape (n_samples,)
> > +        """
> > +        return - np.dot(v, self.intercept_visible_) - np.log(1. +
np.exp(
> > +            safe_sparse_dot(v, self.components_.T) +
self.intercept_hidden_)) \
> > +            .sum(axis=1)
> > +
> > +    def gibbs(self, v):
>
> > If I am not mistaken, the corresponding method in GMMs >
(mixture/gmm.py) is called 'sample'. It would be useful to have the > same
name for API consistency. $0.02: I don't think it's necessarily a good idea
to conflate the two. My reasoning: `sample()`, I'm pretty sure, draws an
independent sample from the model distribution. This is impossible with an
RBM. This executes one step of a Gibbs sampling process, requires an
initial visible state, and importantly does *not* yield independent samples
on successive calls.
> Is this a good enough reason to have different names, or does it warrants
a note in the docstring?

Well, this has a different signature with a non-optional argument that
doesn't appear in `sample`. Having the same name thus doesn't really buy
you anything from an abstraction/generic code perspective. If uniformity
for the mere sake of uniformity is desirable then maybe it's worthwhile but
it seems like they serve different enough purposes (and require different
calling conventions) to be considered conceptually separate.