Model Definitions¶
The model definition is the interface between Determined and the user’s application framework (e.g., Keras, TensorFlow), in terms of loading training data, describing a model architecture, and specifying the underlying iterative optimization training algorithms.
File Structure and Entrypoint¶
A model definition consists of a directory of Python files and an accompanying
entrypoint
that specifies from where to load a trial class. The entrypoint
specification is expected to take the form:
<module>:<object reference>
<module>
specifies the module containing the trial class within the model
definition, relative to the root. It may be an empty string if the model
definition is a Python package and the trial
class is exposed in the top-level __init__.py
file.
<object reference>
specifies the naming of the trial class within the
module. It may be a nested object delimited by dots.
Examples:
:MNistTrial
expects anMNistTrial
class that is exposed in a__init__.py
file at the top level of the model definition.model_def:CIFAR10Trial
expects aCIFAR10Trial
class that is defined in a filemodel_def.py
at the top level of the model definition.determined_lib.trial:trial_classes.NestedTrial
expects aNestedTrial
class that is an attribute oftrial_classes
, wheretrial_classes
is defined in a filedetermined_lib/trial.py
.
Note that this follows the Entry points specification defined in the Python
Packaging User Guide with a single
difference: the directory name of the model definition is prefixed to
<module>
, or used as the module if <module>
is empty.
Since project directories might include large artifacts that should not
be packaged as part of the model definition (e.g., data sets or compiled
binaries), users can optionally include a .detignore
file at the
top level that specifies file paths to be omitted from the model
definition. The .detignore
file uses the same syntax as
.gitignore. Note that
byte-compiled Python files (e.g., .pyc
files or __pycache__
directories) are always ignored.
Model Definition Interfaces¶
To create a model definition, we should implement the Trial
interface
provided by Determined. This interface returns information about the machine
learning task the user wants to perform, like the model architecture to use or
the validation metrics that should be computed.
Determined provides versions of the Trial
interface for each of the
application frameworks it supports. Specifically, Determined currently
supports five types of Trial
interfaces encompassing three
application frameworks:
Best Practices¶
To learn more about some best practices when writing model definitions, see Best Practices for Model Definitions.