Description Usage Arguments Value Author(s) See Also Examples
Functions for training generative neural networks.
1 2 3 
gnn 
GNN object as created by 
data 
(n,d)matrix containing the n ddimensional observations of the training data. 
batch.size 
number of samples used per stochastic gradient step. 
nepoch 
number of epochs (one epoch equals one pass through the complete training dataset while updating the GNN's parameters through stochastic gradient steps). 
verbose 
see 
file 

name 
name under which the trained GNN is saved in 
package 
name of the package from which to read the trained GNN;
if 
... 
additional arguments passed to the underlying

train()
:The trained GNN object.
train_once()
:If object name
exists in
file
, train_once()
reads it,
converts it to a callable GNN object via
to_callable()
and returns it.
Otherwise, train_once()
calls train()
to train the GNN, converts it to a savable
GNN object via to_savable()
, saves it
and returns the trained GNN.
Marius Hofert
GMMN_model()
, VAE_model()
,
to_savable()
, to_callable()
.
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 26 27 28 29 30 31  ## Training data
d < 2
P < matrix(0.9, nrow = d, ncol = d)
diag(P) < 1
A < t(chol(P))
set.seed(271)
ntrn < 60000
Z < matrix(rnorm(ntrn * d), ncol = d)
X < t(A %*% t(Z)) # ddimensional equicorrelated normal
U < apply(abs(X), 2, rank) / (ntrn + 1) # pseudoobservations of X
plot(U[1:2000,], xlab = expression(U[1]), ylab = expression(U[2]))
## Define the model and 'train' it
dim < c(d, 300, d) # dimensions of the input, hidden and output layers
GMMN.mod < GMMN_model(dim)
GMMN.trained < train(GMMN.mod, data = U, batch.size = 500, nepoch = 2)
## Note: Obviously, in a realworld application, batch.size and nepoch
## should be (much) larger (e.g., batch.size = 5000, nepoch = 300).
## Evaluate (roughly picks up the shape even with our bad choices of
## batch.size and nepoch)
set.seed(271)
N.prior < matrix(rnorm(2000 * d), ncol = d)
V < predict(GMMN.trained[["model"]], x = N.prior)
plot(V, xlab = expression(V[1]), ylab = expression(V[2]))
## Convert the trained neural network to one that can be saved
## and save it (here: to some temporary file)
GMMN.savable < to_savable(GMMN.trained)
file < tempfile("trained_GMMN", fileext = ".rda")
save_rda(GMMN.savable, file = file, names = "GMMN")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.