1 Setup

1.1 Packages and options

library(NNbenchmark)
library(kableExtra)
options(scipen = 999)

1.2 Datasets to test

NNdataSummary(NNdatasets)
##      Dataset n_rows n_inputs n_neurons n_parameters
## 1     mDette    500        3         5           26
## 2  mFriedman    500        5         5           36
## 3  mIshigami    500        3        10           51
## 4    mRef153    153        5         3           22
## 5     uDmod1     51        1         6           19
## 6     uDmod2     51        1         5           16
## 7  uDreyfus1     51        1         3           10
## 8  uDreyfus2     51        1         3           10
## 9    uGauss1    250        1         5           16
## 10   uGauss2    250        1         4           13
## 11   uGauss3    250        1         4           13
## 12 uNeuroOne     51        1         2            7

1.3 deepnet trainPredict arguments - inputs x, y

if(dir.exists("D:/GSoC2020/Results/2020run03/"))
{  
  odir <- "D:/GSoC2020/Results/2020run03/"
}else if(dir.exists("~/Documents/recherche-enseignement/code/R/NNbenchmark-project/NNtempresult/"))
{  
  odir <- "~/Documents/recherche-enseignement/code/R/NNbenchmark-project/NNtempresult/"
}else
  odir <- "~"

nrep <- 10
maxit2ndorder  <-    200
maxit1storderA <-   1000
maxit1storderB <-  10000
maxit1storderC <- 100000

#library(deepnet)
deepnet.method <- "BP"
hyperParams.deepnet <- function(optim_method, ...) {

    iter <- maxit1storderA
    lr <- 0.8
    dropout <- 0
    momentum <- 0.95
    hidden_activation <- "sigm"

    out <- list(iter = iter, lr = lr, momentum = momentum, hidden_activation = hidden_activation, dropout = dropout)
    
    return (out)
}

NNtrain.deepnet <- function(x, y, dataxy, formula, hidden_neur, optim_method, hyperParams, ...) {
    
    hyper_params <- do.call(hyperParams, list(optim_method, ...))
    
    iter <- hyper_params$iter
    lr <- hyper_params$lr
    dropout <- hyper_params$dropout
    momentum <- hyper_params$momentum
    hidden_activation <- hyper_params$hidden_activation
    dropout <- hyper_params$dropout

    NNreg <- deepnet::nn.train(x = x, y = y, 
                               hidden = c(hidden_neur), 
                               activationfun = hidden_activation, 
                               learningrate = lr, 
                               output = 'linear', 
                               numepochs = iter, 
                               hidden_dropout = dropout, 
                               momentum = momentum)
    return (NNreg)
}
NNpredict.deepnet <- function(object, x, ...)
    deepnet::nn.predict(nn = object, x = x)
NNclose.deepnet <- function()
  if("package:deepnet" %in% search())
    detach("package:deepnet", unload=TRUE)
deepnet.prepareZZ <- list(xdmv = "m", ydmv = "v", zdm = "d", scale = TRUE)
if(FALSE)
res <- train_and_predict_1data(1, CaDENCE.method, "NNtrain.deepnet", "hyperParams.deepnet", "NNpredict.deepnet", 
                               NNsummary, "NNclose.deepnet", NA, deepnet.prepareZZ, nrep=2, echo=TRUE, doplot=FALSE,
                               pkgname="deepnet", pkgfun="nn.train", rdafile=TRUE, odir=odir)

2 Launch package’s trainPredict

res <- trainPredict_1pkg(1:12, pkgname = "deepnet", pkgfun = "nn.train", deepnet.method,
  prepareZZ.arg = deepnet.prepareZZ, nrep = nrep, doplot = TRUE,
  csvfile = TRUE, rdafile = TRUE, odir = odir, echo = FALSE)

3 Results

#print(res)
kable(t(apply(res, c(1,4), min)))%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
RMSE MSE MAE WAE time
mDette 0.4799 0.2303 0.3682 1.7341 0.60
mFriedman 0.0447 0.0020 0.0344 0.1857 0.61
mIshigami 1.2519 1.5673 0.8581 4.7049 0.75
mRef153 3.4383 11.8219 2.4960 12.5518 0.20
uDmod1 0.0700 0.0049 0.0572 0.1918 0.09
uDmod2 0.0567 0.0032 0.0460 0.1307 0.09
uDreyfus1 0.0154 0.0002 0.0131 0.0374 0.08
uDreyfus2 0.0933 0.0087 0.0741 0.2344 0.08
uGauss1 2.4846 6.1733 1.9766 8.1516 0.29
uGauss2 3.1521 9.9358 2.5812 9.1060 0.29
uGauss3 2.8467 8.1040 2.3023 6.8842 0.28
uNeuroOne 0.2830 0.0801 0.2313 0.5620 0.07
kable(t(apply(res, c(1,4), median)))%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
RMSE MSE MAE WAE time
mDette 1.05695 1.16565 0.93185 2.76185 0.625
mFriedman 0.08260 0.00690 0.06740 0.21195 0.625
mIshigami 1.92090 3.69340 1.40255 8.24455 0.750
mRef153 3.76260 14.15775 2.82650 14.64240 0.200
uDmod1 0.11855 0.01450 0.08510 0.36905 0.100
uDmod2 0.07015 0.00490 0.05630 0.17170 0.095
uDreyfus1 0.08975 0.00825 0.05715 0.29255 0.090
uDreyfus2 0.14590 0.02140 0.10685 0.44765 0.095
uGauss1 4.08135 16.74085 3.22405 12.93110 0.310
uGauss2 5.75700 33.63450 4.56860 15.13745 0.300
uGauss3 3.96515 15.72285 3.10345 11.87410 0.300
uNeuroOne 0.28300 0.08010 0.23140 0.56450 0.090