rGNN: Sampling from a Generative Neural Network

View source: R/rGNN.R

rGNNR Documentation

Sampling from a Generative Neural Network

Description

Sampling method for objects of S3 class "gnn_GNN".

Usage

## 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

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 May 29, 2024, 6:13 a.m.

Related to rGNN in gnn...