library("rplatypus")
spec <- platypus_spec(
data = segmentation_data("train/", "valid/", colormap = binary_colormap),
models = list(u_net("unet", input_shape = c(256, 256)))
)
save_spec(spec, "experiment.yaml")
identical(as.list(platypus_spec("experiment.yaml")), as.list(spec))
# Everything the engine resolved, for a run that has to reproduce in five years.
save_spec(spec, "frozen.yaml", defaults = TRUE)Write a specification back out as YAML
Description
platypus_spec() reads a YAML file and builds a specification from arguments. This is the way back, so the two are one pipeline rather than one and a half: a specification assembled in R becomes a file somebody else can run, or that a script can keep beside its results.
Usage
save_spec(spec, path, defaults = FALSE)
Arguments
spec
|
A platypus_spec, from platypus_spec().
|
path
|
Where to write it. The parent directory must exist. |
defaults
|
Write every field at its resolved value, including the ones you never set. |
Details
It writes what you set, not what the specification holds. A model built from two arguments holds 29 fields once the engine has filled in its defaults, and writing all of them is not merely verbose - it changes what the file does. A model given weights and no architecture takes the architecture from the weights sidecar, and that adoption happens precisely because the field was never set. Freeze the defaults into the file and the adoption can never happen again: the file looks like the original and quietly stops doing what the original did.
defaults = TRUE is the opposite want, and a legitimate one: freeze this run exactly as it resolved so it reproduces years from now. The cost is the paragraph above, by design.
Value
The path, invisibly.
See Also
platypus_spec(), which reads one back, and read_record() for what a run did as opposed to what it was asked to do.