clone: Clone a DBN or RBM

Description Usage Arguments Value Examples

View source: R/clone.R

Description

Clones (= makes a deep copy) of a RestrictedBolzmannMachine or DeepBeliefNet. This is necessary because the weights are stored in an environment which is shared, so any modification you make to the new object will be propagated to the original one, and reciprocally. After cloning, the two objects are totally independent.

Usage

1
2
3
4
5
6
7
clone(x)

## S3 method for class 'RestrictedBolzmannMachine'
clone(x)

## S3 method for class 'DeepBeliefNet'
clone(x)

Arguments

x

the RestrictedBolzmannMachine or DeepBeliefNet object

Value

a clone of x with weights stored in a new environment

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
rbm <- RestrictedBolzmannMachine(Layer(784, "continuous"), Layer(1000, "binary"))
rbm2 <- rbm # Shallow copy
rbm3 <- clone(rbm) # Deep copy

rbm$W[] <- 1
rbm$W[1:10, 1:10] # Should be all 1s
rbm2$W[1:10, 1:10] # May be all 1s
rbm3$W[1:10, 1:10] # Should be all 0s
dbn <- DeepBeliefNet(Layers(c(784, 1000, 500, 250, 30), input="continuous", output="gaussian"))
dbn2 <- clone(dbn)

xrobin/DeepLearning documentation built on Sept. 18, 2020, 5:23 a.m.