Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

parse_flags

Parse Configuration Flags for a TensorFlow Application


Description

Parse configuration flags for a TensorFlow application. Use this to parse and unify the configuration(s) specified through a flags.yml configuration file, alongside other arguments set through the command line.

Usage

parse_flags(
  config = Sys.getenv("R_CONFIG_ACTIVE", unset = "default"),
  file = "flags.yml",
  arguments = commandArgs(TRUE)
)

Arguments

config

The configuration to use. Defaults to the active configuration for the current environment (as specified by the R_CONFIG_ACTIVE environment variable), or default when unset.

file

The configuration file to read.

arguments

The command line arguments (as a character vector) to be parsed.

Value

A named R list, mapping configuration keys to values.

Examples

## Not run: 
# examine an example configuration file provided by tensorflow
file <- system.file("examples/config/flags.yml", package = "tensorflow")
cat(readLines(file), sep = "\n")

# read the default configuration
FLAGS <- tensorflow::parse_flags("default", file = file)
str(FLAGS)

# read the alternate configuration: note that
# the default configuration is inherited, but
# we override the 'string' configuration here
FLAGS <- tensorflow::parse_flags("alternate", file = file)
str(FLAGS)

# override configuration values using command
# line arguments (normally, these would be
# passed in through the command line invocation
# used to start the process)
FLAGS <- tensorflow::parse_flags(
  "alternate",
  file = file,
  arguments = c("--foo=1")
)
str(FLAGS)


## End(Not run)

tensorflow

R Interface to 'TensorFlow'

v2.4.0
Apache License 2.0
Authors
Daniel Falbel [ctb, cph, cre], JJ Allaire [aut, cph], RStudio [cph, fnd], Yuan Tang [aut, cph] (<https://orcid.org/0000-0001-5243-233X>), Dirk Eddelbuettel [ctb, cph], Nick Golding [ctb, cph], Tomasz Kalinowski [ctb, cph], Google Inc. [ctb, cph] (Examples and Tutorials)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.