CRAN Package Check Results for Package gnn

Last updated on 2024-02-21 16:51:28 CET.

Flavor Version Tinstall Tcheck Ttotal Status Flags
r-devel-linux-x86_64-debian-clang 0.0-3 ERROR
r-devel-linux-x86_64-debian-gcc 0.0-3 9.72 77.05 86.77 ERROR
r-devel-linux-x86_64-fedora-clang 0.0-3 157.06 OK
r-devel-linux-x86_64-fedora-gcc 0.0-3 152.18 OK
r-devel-windows-x86_64 0.0-3 12.00 90.00 102.00 OK
r-patched-linux-x86_64 0.0-3 17.91 108.09 126.00 OK
r-release-linux-x86_64 0.0-3 12.17 108.42 120.59 OK
r-release-macos-arm64 0.0-3 43.00 OK
r-release-macos-x86_64 0.0-3 64.00 OK
r-release-windows-x86_64 0.0-3 14.00 107.00 121.00 OK
r-oldrel-macos-arm64 0.0-3 41.00 OK
r-oldrel-windows-x86_64 0.0-3 15.00 109.00 124.00 OK

Check Details

Version: 0.0-3
Check: examples
Result: ERROR Running examples in ‘gnn-Ex.R’ failed The error most likely occurred in: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: FNN > ### Title: Generative Moment Matching Network > ### Aliases: FNN > ### Keywords: models > > ### ** Examples > > if(TensorFlow_available()) { # rather restrictive (due to R-Forge, winbuilder) + library(gnn) # for being standalone + + ## Training data + d <- 2 # bivariate case + P <- matrix(0.9, nrow = d, ncol = d); diag(P) <- 1 # correlation matrix + ntrn <- 60000 # training data sample size + set.seed(271) + library(nvmix) + X <- rNorm(ntrn, scale = P) # N(0,P) samples + X. <- abs(X) # |X| + + ## Plot a subsample + m <- 2000 # subsample size for plots + opar <- par(pty = "s") + plot(X.[1:m,], xlab = expression(X[1]), ylab = expression(X[2])) # plot |X| + U <- apply(X., 2, rank) / (ntrn + 1) # pseudo-observations of |X| + plot(U[1:m,], xlab = expression(U[1]), ylab = expression(U[2])) # visual check + + ## Model 1: A basic feedforward neural network (FNN) with MSE loss function + fnn <- FNN(c(d, 300, d), loss.fun = "MSE") # define the FNN + fnn <- fitGNN(fnn, data = U, n.epoch = 40) # train with batch optimization + plot(fnn, plot.type = "loss") # plot the loss after each epoch + + ## Model 2: A GMMN (FNN with MMD loss function) + gmmn <- FNN(c(d, 300, d)) # define the GMMN (initialized with random weights) + ## For training we need to use a mini-batch optimization (batch size < nrow(U)). + ## For a fair comparison (same number of gradient steps) to NN, we use 500 + ## samples (25% = 4 gradient steps/epoch) for 10 epochs for GMMN. + library(keras) # for callback_early_stopping() + ## We monitor the loss function and stop earlier if the loss function + ## over the last patience-many epochs has changed by less than min_delta + ## in absolute value. Then we keep the weights that led to the smallest + ## loss seen throughout training. + gmmn <- fitGNN(gmmn, data = U, batch.size = 500, n.epoch = 10, + callbacks = callback_early_stopping(monitor = "loss", + min_delta = 1e-3, patience = 3, + restore_best_weights = TRUE)) + plot(gmmn, plot.type = "loss") # plot the loss after each epoch + ## Note: + ## - Obviously, in a real-world application, batch.size and n.epoch + ## should be (much) larger (e.g., batch.size = 5000, n.epoch = 300). + ## - Training is not reproducible (due to keras). + + ## Model 3: A FNN with CvM loss function + fnnCvM <- FNN(c(d, 300, d), loss.fun = "CvM") + fnnCvM <- fitGNN(fnnCvM, data = U, batch.size = 500, n.epoch = 10, + callbacks = callback_early_stopping(monitor = "loss", + min_delta = 1e-3, patience = 3, + restore_best_weights = TRUE)) + plot(fnnCvM, plot.type = "loss") # plot the loss after each epoch + + ## Sample from the different models + set.seed(271) + V.fnn <- rGNN(fnn, size = m) + set.seed(271) + V.gmmn <- rGNN(gmmn, size = m) + set.seed(271) + V.fnnCvM <- rGNN(fnnCvM, size = m) + + ## Joint plot of training subsample with GMMN PRNs. Clearly, the MSE + ## cannot be used to learn the distribution correctly. + layout(matrix(1:4, ncol = 2, byrow = TRUE)) + plot(U[1:m,], xlab = expression(U[1]), ylab = expression(U[2]), cex = 0.2) + mtext("Training subsample", side = 4, line = 0.4, adj = 0) + plot(V.fnn, xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MSE loss", side = 4, line = 0.4, adj = 0) + plot(V.gmmn, xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MMD loss", side = 4, line = 0.4, adj = 0) + plot(V.fnnCvM, xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with CvM loss", side = 4, line = 0.4, adj = 0) + + ## Joint plot of training subsample with GMMN QRNs + library(qrng) # for sobol() + V.fnn. <- rGNN(fnn, size = m, method = "sobol", randomize = "Owen") + V.gmmn. <- rGNN(gmmn, size = m, method = "sobol", randomize = "Owen") + V.fnnCvM. <- rGNN(fnnCvM, size = m, method = "sobol", randomize = "Owen") + plot(U[1:m,], xlab = expression(U[1]), ylab = expression(U[2]), cex = 0.2) + mtext("Training subsample", side = 4, line = 0.4, adj = 0) + plot(V.fnn., xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MSE loss", side = 4, line = 0.4, adj = 0) + plot(V.gmmn., xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MMD loss", side = 4, line = 0.4, adj = 0) + plot(V.fnnCvM., xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with CvM loss", side = 4, line = 0.4, adj = 0) + layout(1) + par(opar) + + } Error: Valid installation of TensorFlow not found. Python environments searched for 'tensorflow' package: /usr/bin/python3.11 Python exception encountered: Traceback (most recent call last): File "/home/hornik/tmp/R.check/r-devel-clang/Work/build/Packages/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook return _run_hook(name, _hook) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/hornik/tmp/R.check/r-devel-clang/Work/build/Packages/reticulate/python/rpytools/loader.py", line 93, in _run_hook module = hook() ^^^^^^ File "/home/hornik/tmp/R.check/r-devel-clang/Work/build/Packages/reticulate/python/rpytools/loader.py", line 117, in _hook return _find_and_load(name, import_) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'tensorflow' You can install TensorFlow using the install_tensorflow() function. Execution halted Flavor: r-devel-linux-x86_64-debian-clang

Version: 0.0-3
Check: examples
Result: ERROR Running examples in ‘gnn-Ex.R’ failed The error most likely occurred in: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: FNN > ### Title: Generative Moment Matching Network > ### Aliases: FNN > ### Keywords: models > > ### ** Examples > > if(TensorFlow_available()) { # rather restrictive (due to R-Forge, winbuilder) + library(gnn) # for being standalone + + ## Training data + d <- 2 # bivariate case + P <- matrix(0.9, nrow = d, ncol = d); diag(P) <- 1 # correlation matrix + ntrn <- 60000 # training data sample size + set.seed(271) + library(nvmix) + X <- rNorm(ntrn, scale = P) # N(0,P) samples + X. <- abs(X) # |X| + + ## Plot a subsample + m <- 2000 # subsample size for plots + opar <- par(pty = "s") + plot(X.[1:m,], xlab = expression(X[1]), ylab = expression(X[2])) # plot |X| + U <- apply(X., 2, rank) / (ntrn + 1) # pseudo-observations of |X| + plot(U[1:m,], xlab = expression(U[1]), ylab = expression(U[2])) # visual check + + ## Model 1: A basic feedforward neural network (FNN) with MSE loss function + fnn <- FNN(c(d, 300, d), loss.fun = "MSE") # define the FNN + fnn <- fitGNN(fnn, data = U, n.epoch = 40) # train with batch optimization + plot(fnn, plot.type = "loss") # plot the loss after each epoch + + ## Model 2: A GMMN (FNN with MMD loss function) + gmmn <- FNN(c(d, 300, d)) # define the GMMN (initialized with random weights) + ## For training we need to use a mini-batch optimization (batch size < nrow(U)). + ## For a fair comparison (same number of gradient steps) to NN, we use 500 + ## samples (25% = 4 gradient steps/epoch) for 10 epochs for GMMN. + library(keras) # for callback_early_stopping() + ## We monitor the loss function and stop earlier if the loss function + ## over the last patience-many epochs has changed by less than min_delta + ## in absolute value. Then we keep the weights that led to the smallest + ## loss seen throughout training. + gmmn <- fitGNN(gmmn, data = U, batch.size = 500, n.epoch = 10, + callbacks = callback_early_stopping(monitor = "loss", + min_delta = 1e-3, patience = 3, + restore_best_weights = TRUE)) + plot(gmmn, plot.type = "loss") # plot the loss after each epoch + ## Note: + ## - Obviously, in a real-world application, batch.size and n.epoch + ## should be (much) larger (e.g., batch.size = 5000, n.epoch = 300). + ## - Training is not reproducible (due to keras). + + ## Model 3: A FNN with CvM loss function + fnnCvM <- FNN(c(d, 300, d), loss.fun = "CvM") + fnnCvM <- fitGNN(fnnCvM, data = U, batch.size = 500, n.epoch = 10, + callbacks = callback_early_stopping(monitor = "loss", + min_delta = 1e-3, patience = 3, + restore_best_weights = TRUE)) + plot(fnnCvM, plot.type = "loss") # plot the loss after each epoch + + ## Sample from the different models + set.seed(271) + V.fnn <- rGNN(fnn, size = m) + set.seed(271) + V.gmmn <- rGNN(gmmn, size = m) + set.seed(271) + V.fnnCvM <- rGNN(fnnCvM, size = m) + + ## Joint plot of training subsample with GMMN PRNs. Clearly, the MSE + ## cannot be used to learn the distribution correctly. + layout(matrix(1:4, ncol = 2, byrow = TRUE)) + plot(U[1:m,], xlab = expression(U[1]), ylab = expression(U[2]), cex = 0.2) + mtext("Training subsample", side = 4, line = 0.4, adj = 0) + plot(V.fnn, xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MSE loss", side = 4, line = 0.4, adj = 0) + plot(V.gmmn, xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MMD loss", side = 4, line = 0.4, adj = 0) + plot(V.fnnCvM, xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with CvM loss", side = 4, line = 0.4, adj = 0) + + ## Joint plot of training subsample with GMMN QRNs + library(qrng) # for sobol() + V.fnn. <- rGNN(fnn, size = m, method = "sobol", randomize = "Owen") + V.gmmn. <- rGNN(gmmn, size = m, method = "sobol", randomize = "Owen") + V.fnnCvM. <- rGNN(fnnCvM, size = m, method = "sobol", randomize = "Owen") + plot(U[1:m,], xlab = expression(U[1]), ylab = expression(U[2]), cex = 0.2) + mtext("Training subsample", side = 4, line = 0.4, adj = 0) + plot(V.fnn., xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MSE loss", side = 4, line = 0.4, adj = 0) + plot(V.gmmn., xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with MMD loss", side = 4, line = 0.4, adj = 0) + plot(V.fnnCvM., xlab = expression(V[1]), ylab = expression(V[2]), cex = 0.2) + mtext("Trained NN with CvM loss", side = 4, line = 0.4, adj = 0) + layout(1) + par(opar) + + } Error: Valid installation of TensorFlow not found. Python environments searched for 'tensorflow' package: /usr/bin/python3.11 Python exception encountered: Traceback (most recent call last): File "/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook return _run_hook(name, _hook) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/reticulate/python/rpytools/loader.py", line 93, in _run_hook module = hook() ^^^^^^ File "/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/reticulate/python/rpytools/loader.py", line 117, in _hook return _find_and_load(name, import_) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'tensorflow' You can install TensorFlow using the install_tensorflow() function. Execution halted Flavor: r-devel-linux-x86_64-debian-gcc