Bernoulli Restricted Boltzmann Machine (RBM).
A Restricted Boltzmann Machine with binary visible units and binary hidden units. Parameters are estimated using Stochastic Maximum Likelihood (SML), also known as Persistent Contrastive Divergence (PCD) [2].
The time complexity of this implementation is O(d ** 2) assuming d ~ n_features ~ n_components.
Read more in the User Guide.
Number of binary hidden units.
The learning rate for weight updates. It is highly recommended to tune this hyper-parameter. Reasonable values are in the 10**[0., -3.] range.
Number of examples per minibatch.
Number of iterations/sweeps over the training dataset to perform during training.
The verbosity level. The default, zero, means silent mode. Range of values is [0, inf].
Determines random number generation for:
Pass an int for reproducible results across multiple function calls. See Glossary.
Biases of the hidden units.
Biases of the visible units.
Weight matrix, where n_features is the number of visible units and n_components is the number of hidden units.
Hidden Activation sampled from the model distribution, where batch_size is the number of examples per minibatch and n_components is the number of hidden units.
Number of features seen during fit.
Added in version 0.24.
n_features_in_,)
Names of features seen during fit. Defined only when X has feature names that are all strings.
Added in version 1.0.
See also
sklearn.neural_network.MLPRegressorMulti-layer Perceptron regressor.
sklearn.neural_network.MLPClassifierMulti-layer Perceptron classifier.
sklearn.decomposition.PCAAn unsupervised linear dimensionality reduction model.
deep belief nets. Neural Computation 18, pp 1527-1554. https://www.cs.toronto.edu/~hinton/absps/fastnc.pdf
Approximations to the Likelihood Gradient. International Conference on Machine Learning (ICML) 2008
>>> import numpy as np >>> from sklearn.neural_network import BernoulliRBM >>> X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]) >>> model = BernoulliRBM(n_components=2) >>> model.fit(X) BernoulliRBM(n_components=2)
For a more detailed example usage, see Restricted Boltzmann Machine features for digit classification.
Fit the model to the data X.
Training data.
Target values (None for unsupervised transformations).
The fitted model.
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
Get output feature names for transformation.
The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: ["class_name0", "class_name1", "class_name2"].
Only used to validate feature names with the names seen in fit.
Transformed feature names.
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
A MetadataRequest encapsulating routing information.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Perform one Gibbs sampling step.
Values of the visible layer to start from.
Values of the visible layer after one Gibbs step.
Fit the model to the partial segment of the data X.
Training data.
Target values (None for unsupervised transformations).
The fitted model.
Compute the pseudo-likelihood of X.
Values of the visible layer. Must be all-boolean (not checked).
Value of the pseudo-likelihood (proxy for likelihood).
This method is not deterministic: it computes a quantity called the free energy on X, then on a randomly corrupted version of X, and returns the log of the logistic function of the difference.
Set output container.
See Introducing the set_output API for an example on how to use the API.
Configure output of transform and fit_transform.
"default": Default output format of a transformer"pandas": DataFrame output"polars": Polars outputNone: Transform configuration is unchangedAdded in version 1.4: "polars" option was added.
Estimator instance.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Compute the hidden layer activation probabilities, P(h=1|v=X).
The data to be transformed.
Latent representations of the data.
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.neural_network.BernoulliRBM.html