Configuration Files
Values in spock are set using external configuration files.
Supported Configuration Formats#
YAML#
- Requires file extension of
.yaml. - Supported using the external
PyYAMLlibrary.
TOML#
- Requires file extension of
.toml. - Supported using the external
tomllibrary.
JSON#
- Requires file extension of
.json. - Supported using the built-in
jsonmodule.
Creating a Configuration File#
Recall that we defined our spock class as such:
class Activation(Enum): relu = 'relu' gelu = 'gelu' tanh = 'tanh'
@spockclass ModelConfig: n_features: int dropout: List[float] hidden_sizes: Tuple[int, int, int] activation: ActivationNote that all of the types of our parameters int, List, Tuple, and Activation are required types. This
means that if we do not specify values for these parameters in our configuration file spock will throw an Exception.
Let's create our configuration file using the YAML standard: tutorial.yaml
################# tutorial.yaml################# ModelConfign_features: 64dropout: [0.2, 0.1]hidden_sizes: [32, 32, 16]activation: relu