rGNN: Sampling from a Generative Neural Network

Description Usage Arguments Value Author(s) Examples

View source: R/rGNN.R

Description

Sampling method for objects of S3 class "gnn_GNN".

Usage

1
2
## S3 method for class 'gnn_GNN'
rGNN(x, size, prior = NULL, pobs = FALSE, ...)

Arguments

x

object of S3 class "gnn_GNN".

size

sample size, a positive integer. Ignored if prior is a matrix.

prior

one of

NULL

the default, generates independent N(0,1) realizations as prior sample.

matrix

passes the given sample through the GNN x. Such a matrix is internally (if prior = NULL) and typically obtained via rPrior().

pobs

logical indicating whether the pseudo-observations of the generated samples should be returned.

...

additional arguments passed to the underlying rPrior() if prior = NULL.

Value

(size, dim(x)[1])-matrix of samples.

Author(s)

Marius Hofert

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
if(TensorFlow_available()) { # rather restrictive (due to R-Forge, winbuilder)
library(gnn) # for being standalone

## Define dummy model
d <- 2 # bivariate case
GMMN <- FNN(c(d, 300, d)) # Feedforward NN with MMD loss (a GMMN; random weights)

## Sampling
n <- 3
(X1 <- rGNN(GMMN, size = n)) # default (independent N(0,1) samples as prior)
(X2 <- rGNN(GMMN, size = n, # passing additional arguments to rPrior()
            qmargins = qexp, method = "sobol", seed = 271))
(X3 <- rGNN(GMMN, prior = matrix(rexp(n * d), ncol = d))) # providing 'prior'
stopifnot(dim(X1) == c(n, d), dim(X2) == c(n, d), dim(X3) == c(n, d))

}

gnn documentation built on Sept. 20, 2021, 5:13 p.m.

Related to rGNN in gnn...