rbm_gpu: Fit a Restricted Boltzmann Machine

Description Usage Arguments Details Value References Examples

Description

This function fits an RBM to the input dataset. It internally uses sparse matricies for faster matrix operations

Usage

1
2
3
4
5
rbm_gpu(x, num_hidden = 10, max_epochs = 1000, learning_rate = 0.1,
  use_mini_batches = TRUE, batch_size = 250, initial_weights_mean = 0,
  initial_weights_sd = 0.1, momentum = 0, dropout = FALSE,
  dropout_pct = 0.5, retx = FALSE, activation_function = NULL,
  verbose = FALSE, ...)

Arguments

x

a sparse matrix

num_hidden

number of neurons in the hidden layer

max_epochs

Maximum learning epochs

learning_rate

Learning Rate

use_mini_batches

Use sub-samples for training for each iteration. This usually results in MUCH faster learning.

batch_size

Sample size for mini batches

initial_weights_mean

Mean of initial random weights

initial_weights_sd

Standard deviation of initial random weights

momentum

Use momentum when learning. (Helps move faster through "half pipe" shaped regions).

dropout

Use dropout when learning (sort of a form of regularization).

dropout_pct

What percent of neurons to drop out (0 to 1)

retx

whether to return the RBM predictions for the input data

activation_function

function to convert hidden activations (-Inf, Inf) to hidden probabilities [0, 1]. Must be able to operate on sparse "Matrix" objects.

verbose

Print lots of messages while training

...

not used

Details

This code is (mostly) adapted from edwin chen's python code for RBMs, avaiable here: https://github.com/echen/restricted-boltzmann-machines. Some modifications (e.g. momentum) were adapted from Andrew Landgraf's R code for RBMs, available here: http://alandgraf.blogspot.com/2013/01/restricted-boltzmann-machines-in-r.html.

Value

a rbm object

References

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
#Setup a dataset
set.seed(10)
data(movie_reviews)
data(george_reviews)

#Fit a PCA model and an RBM model
PCA <- prcomp(movie_reviews, retx=TRUE)
RBM <- rbm_gpu(movie_reviews, retx=TRUE)

#Examine the 2 models
round(PCA$rotation, 2) #PCA weights
round(RBM$rotation, 2) #RBM weights

#Predict for new data
predict(PCA, george_reviews)
predict(RBM, george_reviews, type='activations')
predict(RBM, george_reviews, type='probs')
predict(RBM, george_reviews, type='states')

#Predict for existing data
predict(PCA)
predict(RBM, type='probs')

## End(Not run)

zachmayer/rbm documentation built on May 4, 2019, 9:07 p.m.