RBMLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a Restricted Boltzmann Machine (RBM) layer for neural networks.
Inheritance: LayerBase<T> → RBMLayer<T>
Implements: IShapeContract
For Beginners
An RBM layer is like a feature detector that can learn patterns in data.
Imagine you have a set of movie ratings:
- The visible layer represents the actual ratings
- The hidden layer represents abstract features (e.g., “likes action”, “prefers comedy”)
- The RBM learns to connect ratings to these abstract features
RBM layers are useful for:
- Finding underlying patterns in data
- Reducing the dimensionality of data
- Initializing weights for deep neural networks
How It Works
An RBM layer is a stochastic neural network layer that learns a probability distribution over its inputs. It consists of a visible layer and a hidden layer with no connections between nodes within the same layer.
Constructors
| Constructor | Summary |
|---|---|
RBMLayer(int hiddenUnits, IActivationFunction<T> scalarActivation) |
Lazy ctor — visible-unit count is resolved from input.Shape[^1] on the first Forward call. |
RBMLayer(int visibleUnits, int hiddenUnits, IActivationFunction<T> scalarActivation) |
Initializes a new instance of the RBMLayer class with vector activation. |
RBMLayer(int visibleUnits, int hiddenUnits, IVectorActivationFunction<T> vectorActivation) |
Initializes a new instance of the RBMLayer class with vector activation. |
Properties
| Property | Summary |
|---|---|
bool IsInitialized { get; } |
|
bool SupportsTraining { get; } |
Indicates whether this layer supports training. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, string> GetParameterRoles() |
Returns parameter roles for per-role optimizer configuration (e.g., weight decay exemption for biases). |
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
IReadOnlyList<Tensor<T>> GetTrainableParameters() |
Returns all trainable parameter tensors marked with [TrainableParameter]. |
void ClearGradients() |
|
void ResetState() |
|
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void TrainWithContrastiveDivergence(Vector<T> input, T learningRate, int kSteps) |
Trains the RBM with a tensor whose last axis is the visible-unit axis. |
void UpdateParameters(T learningRate) |
Updates the layer’s parameters using either standard backpropagation or contrastive divergence. |
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |