funKerasMnist_0 | R Documentation |
Hyperparameter Tuning: Keras MNIST Classification Test Function.
funKerasMnist_0(x, kerasConf, data)
x |
matrix of hyperparameter values to evaluate with the function. Rows for points and columns for dimension. |
kerasConf |
List of additional parameters passed to keras as described in |
data |
mnist data set. Default: |
Trains a simple deep NN on the MNIST dataset. Provides a template that can be used for other networks as well. Standard Code from https://tensorflow.rstudio.com/ Modified by T. Bartz-Beielstein (tbb@bartzundbartz.de)
1-column matrix with resulting function values (test loss)
getKerasConf
evalKerasMnist
fit
### These examples require an activated Python environment as described in ### Bartz-Beielstein, T., Rehbach, F., Sen, A., and Zaefferer, M.: ### Surrogate Model Based Hyperparameter Tuning for Deep Learning with SPOT, ### June 2021. http://arxiv.org/abs/2105.14625. PYTHON_RETICULATE <- FALSE if(PYTHON_RETICULATE){ library("SPOTMisc") library("SPOT") kerasConf <- getKerasConf() ## The following two settings are default: kerasConf$encoding = "oneHot" kerasConf$model = "dl" cfg <- getModelConf(kerasConf$model) x <- matrix(cfg$default, nrow=1) transformFun <- cfg$transformations types <- cfg$type lower <- cfg$lower upper <- cfg$upper ### First example: simple function call: x <- matrix(lower, 1,) funKerasMnist(x, kerasConf = kerasConf) ### Use convnet: kerasConf$encoding <- "tensor" kerasConf$model <- "cnn" funKerasMnist(x, kerasConf = kerasConf) ### Second example: evaluation of several (three) hyperparameter settings: xxx <- rbind(x,x,x) funKerasMnist(xxx, kerasConf = kerasConf) ### Third example: spot call (dense network): kerasConf$verbose <- 1 data <- getMnistData() res <- spot(x = NULL, fun = funKerasMnist, lower = lower, upper = upper, control = list(funEvals=15, noise = TRUE, types = types, plots = TRUE, progress = TRUE, seedFun = 1, seedSPOT = 1), kerasConf = kerasConf, data = data) ### Fourth example: spot call (convnet): kerasConf$verbose <- 1 kerasConf$encoding <- "tensor" kerasConf$model <- "cnn" data <- getMnistData(kerasConf) res <- spot(x = NULL, fun = funKerasMnist, lower = lower, upper = upper, control = list(funEvals=15, noise = TRUE, types = types, plots = TRUE, progress = TRUE, seedFun = 1, seedSPOT = 1), kerasConf = kerasConf, data = data) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.