Instrument Model CodeΒΆ

Determined injects hyperparameters from the experiment configuration into model code via a context object in the Trial base class. This TrialContext object exposes a get_hparam() method that takes the hyperparameter name. At trial runtime, Determined injects a value for the hyperparameter. For example, to inject the value of the dropout_probability hyperparameter defined above into the constructor of a PyTorch Dropout layer:

nn.Dropout(p=self.context.get_hparam("dropout_probability"))

To see hyperparameter injection throughout a complete trial implementation, refer to the Training APIs.