View source: R/prepareData.keras.R
prepareData.keras | R Documentation |
Configuration of data for flexible downscaling keras experiment definition
prepareData.keras(
x,
y,
global.vars = NULL,
combined.only = TRUE,
spatial.predictors = NULL,
local.predictors = NULL,
first.connection = c("dense", "conv"),
last.connection = c("dense", "conv"),
channels = c("first", "last"),
time.frames = NULL
)
x |
A grid (usually a multigrid) of predictor fields |
y |
A grid (usually a stations grid, but not necessarily) of observations (predictands) |
global.vars |
An optional character vector with the short names of the variables of the input |
combined.only |
Optional, and only used if spatial.predictors parameters are passed. Should the combined PC be used as the only
global predictor? Default to TRUE. Otherwise, the combined PC constructed with |
spatial.predictors |
Default to |
local.predictors |
Default to
Note that grid 'y' has to be single-site, otherwise this will cause errors in the model training, since downscaleTrain.keras is designed to store only one model at a time due to Keras particularities. If your desire is to downscale to multiple-sites for independent models, please loop over this function for the different sites. |
first.connection |
A string. Possible values are c("dense","conv") depending on whether the first connection (i.e., input layer to first hidden layer) is dense or convolutional. |
last.connection |
A string. Same as |
channels |
A string. Possible values are c("first","last") and indicates the dimension of the channels (i.e., climate variables) in the array. If "first" then dimensions = c("channel","latitude","longitude") for regular grids or c("channel","loc") for irregular grids. If "last" then dimensions = c("latitude","longitude","channel") for regular grids or c("loc","channel") for irregular grids. |
time.frames |
The number of time frames to build the recurrent neural network. If e.g., time.frame = 2, then the value
y(t) is a function of x(t) and x(t-1). The time frames stack in the input array prior to the input neurons or channels (in conv. layers).
See |
Remove days containing NA in at least one predictand site.
A named list with components y
(the predictand), x.global
(global predictors) and other attributes. For the case when
spatial and local predictors are both computed, these are stacked together in the x.global
object.
J. BaƱo-Medina
downscaleTrain.keras for training a downscaling deep model with keras downscalePredict.keras for predicting with a keras model prepareNewData.keras for predictor preparation with new (test) data downscaleR.keras Wiki
downscaleR Wiki for preparing predictors for downscaling and seasonal forecasting.
require(climate4R.datasets)
# Loading data
require(transformeR)
require(downscaleR)
data("VALUE_Iberia_tas")
y <- VALUE_Iberia_tas
data("NCEP_Iberia_hus850", "NCEP_Iberia_psl", "NCEP_Iberia_ta850")
x <- makeMultiGrid(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)
# We standardize the predictors using transformeR function scaleGrid
x <- scaleGrid(x,type = "standardize")
# Preparing the predictors
data <- prepareData.keras(x = x, y = y,
first.connection = "conv",
last.connection = "dense",
channels = "last")
# We can visualize the outputield not imported f
str(data)
# We can call prepareData.keras to compute PCs over the predictor field
data <- prepareData.keras(x = x, y = y,
spatial.predictors = list(v.exp = 0.95), # the EOFs that explain the 95% of the total variance
first.connection = "dense",
last.connection = "dense",
channels = "last")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.