Sets random seeds for R and Keras to support reproducible neural network
training. This is a convenience wrapper around
set.seed and set_random_seed.
Details
Neural network training involves randomness from R (data shuffling and CV fold creation) and Keras/TensorFlow (weight initialization and dropout).
Seed both to reproduce a training run as closely as possible. Call this function immediately before each training call because landscape generation and other R operations advance R's random-number stream. Minor variations may still occur across different hardware and software configurations.
See also
Other neural network training:
save_pixel_model(),
train_metric_model(),
train_pixel_model()
Examples
if (FALSE) { # requireNamespace("reticulate", quietly = TRUE) && reticulate::virtualenv_exists("r-keras")
# Generate reproducible training data
set.seed(42)
landscapes <- create_landscapes(n = 6, patterns = c("sharp", "random"))
# Reset both random-number generators immediately before training
set_random_seed(42)
model <- train_pixel_model(landscapes, cv_method = "none", epochs = 5)
}
