Parameters are injected into the command by replacing any Valohai parameter placeholders defined further below. Good examples of parameters would be “learning rate” number or “network layout” string.
A parameter in parameters
has 2 required and 5 optional properties:
name
: the parameter name, shown on the user interfacetype
: the parameter type, valid values arefloat
,integer
,string
andflag
pass-as
: (optional) how the parameter is passed to the commanddescription
: (optional) more detailed human-readable description of the parameterdefault
: (optional) the default value of the parameteroptional
: (optional) marks that this input is optional and the value can be left undefinedchoices
: (optional) list of alternative values, shown as a dropdown menu in the UI
Using the flag parameter
optional
has no effect for the flag
type. It either exists or doesn’t. If it’s always on, you can type it into the command.
If pass-as
is not defined, the parameter is passed as --<PARAMETER_NAME>={v}
, you can customize this by specifying {v}
in the pass-as
e.g. -t {v}
where {v}
becomes the actual value.
flag
type defaults to just --<PARAMETER_NAME>
when set to true. When set to false, nothing is passed.
The note above implies that when you want to pass a flag with the value false
, you will need to use a special version of the pass-as
property.
pass-true-as: --<PARAMETER_NAME>=true
pass-false-as: --<PARAMETER_NAME>=false
choices
The choices
property lets you to define a list of alternative values for the parameter. The value for the execution can be chosen by using a dropdown menu in the UI.
parameters:
- name: color
type: string
default: blue
description: Choose a color
optional: false
choices:
- blue
- red
- green
{parameters}
placeholder
{parameters}
injects all parameters to its position in the commands.
For example:
- step:
name: train-model
image: python:3.6
command:
- python train.py {parameters}
parameters:
- name: max-steps
type: integer
description: Number of steps to run the trainer
default: 300
- name: learning-rate
type: float
pass-as: --lr={v}
description: Initial learning rate
default: 0.001
- name: architecture
type: string
pass-as: arc {v}
default: 10xRELU-SoftMax
optional: true
The above would generate the following command by default:
python train.py --max-steps=300 --lr=0.001 arc 10xRELU-SoftMax
flag
.
Flags will only ever appear, if they are defined with value set to true.
{parameter:<NAME>}
placeholder
You can also use singular parameters using the {parameter:<NAME>}
syntax.
For example:
- step:
name: preprocess-and-train
image: python:3.6
command:
- python preprocess.py {parameter:train-split}
- python train.py {parameter:learning-rate}
parameters:
- name: train-split
type: integer
default: 80
- name: learning-rate
pass-as: --lr={v}
type: float
default: 0.001
The above would generate the following commands by default:
python preprocess.py --train-split=80
python train.py --lr=0.001
{parameter-value:<NAME>}
placeholder
If you wish to ignore pass-as
definition, you can use {parameter-value:<NAME>}
to pass only the parameter value. This is essentially the same as defining pass-as: "{v}"
.
For example:
- step:
name: preprocess
image: python:3.6
command:
- python preprocess.py {parameter-value:train-split} {parameter-value:style}
parameters:
- name: train-split
type: integer
default: 80
- name: style
pass-as: -s={v}
type: string
default: nested
The above would generate the following command by default:
python preprocess.py 80 nested
Comments
0 comments
Please sign in to leave a comment.