RBM: Restricted Boltzmann Machine

Description Usage Arguments Value Examples

Description

Trains a Restricted Boltzmann Machine on binary data, either supervised or unsupervised. This function uses contrastive diversion with k = 1 for training the system.

Usage

1
2
3
RBM(x, y, n.iter = 100, n.hidden = 30, learning.rate = 0.1,
  plot = FALSE, size.minibatch = 10, momentum = 0.5,
  lambda = 0.001)

Arguments

x

A matrix with binary features of shape samples * features.

y

A matrix with labels for the data, only when training a classification RBM. (Optional)

n.iter

Defines the number of epochs to run contrastive diversion.

n.hidden

The number of nodes in the hidden layer.

learning.rate

The learning rate, alpha, for training the system.

plot

Whether to plot the learning progress of the weights

size.minibatch

The size of the minibatches used for training.

momentum

Speeds up the gradient descent learning.

lambda

The sparsity penalty lambda to prevent the system from overfitting.

Value

A list with the trained weights of the RBM that can be used for the predict RBM function when supervised learning was applied or the ReconstructRBM function to reconstruct data with the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Load the MNIST data
data(MNIST)

# Fit unsupervised RBM with the MNIST data
modelRBM <- RBM(MNIST$trainX, n.iter = 1000, n.hidden = 30, learning.rate = 0.1, 
plot = FALSE, size.minibatch = 10, momentum = 0.5, lambda = 0.001)

# Fit a supervised RBM with the MNIST data
modelRBMSup <- RBM(MNIST$trainX, MNIST$trainY, n.iter = 1000, n.hidden = 30, learning.rate = 0.1, 
plot = FALSE, size.minibatch = 10, momentum = 0.5, lambda = 0.001)

# Add more weight decay when training more parameters
modelRBMSup <- RBM(MNIST$trainX, MNIST$trainY, n.iter = 1000, n.hidden = 100, learning.rate = 0.1, 
plot = FALSE, size.minibatch = 10, momentum = 0.5, lambda = 0.1)

TimoMatzen/RBM documentation built on June 1, 2019, 8:35 a.m.