示例#1
0
 def test_use_model_list(self):
     self.assertFalse(
         use_model_list(Xs=self.Xs, botorch_model_class=SingleTaskGP))
     self.assertFalse(  # Batched multi-output case.
         use_model_list(Xs=self.Xs * 2, botorch_model_class=SingleTaskGP))
     self.assertTrue(
         use_model_list(Xs=self.Xs + self.Xs2,
                        botorch_model_class=SingleTaskGP))
示例#2
0
 def _autoset_surrogate(
     self,
     Xs: List[Tensor],
     Ys: List[Tensor],
     Yvars: List[Tensor],
     task_features: List[int],
     fidelity_features: List[int],
     metric_names: List[str],
 ) -> None:
     """Sets a default surrogate on this model if one was not explicitly
     provided.
     """
     # To determine whether to use `ListSurrogate`, we need to check for
     # the batched multi-output case, so we first see which model would
     # be chosen given the Yvars and the properties of data.
     botorch_model_class = choose_model_class(
         Yvars=Yvars,
         task_features=task_features,
         fidelity_features=fidelity_features,
     )
     if use_model_list(Xs=Xs, botorch_model_class=botorch_model_class):
         # If using `ListSurrogate` / `ModelListGP`, pick submodels for each
         # outcome.
         botorch_submodel_class_per_outcome = {
             metric_name: choose_model_class(
                 Yvars=[Yvar],
                 task_features=task_features,
                 fidelity_features=fidelity_features,
             )
             for Yvar, metric_name in zip(Yvars, metric_names)
         }
         self._surrogate = ListSurrogate(
             botorch_submodel_class_per_outcome=
             botorch_submodel_class_per_outcome,
             **self.surrogate_options,
         )
     else:
         # Using regular `Surrogate`, so botorch model picked at the beginning
         # of the function is the one we should use.
         self._surrogate = Surrogate(
             botorch_model_class=botorch_model_class,
             **self.surrogate_options)