def __init__(self, dataset_properties: Dict[str, BaseDatasetPropertiesType], random_state: Optional[np.random.RandomState] = None): super().__init__(dataset_properties=dataset_properties, random_state=random_state) self.run_summary: Optional[RunSummary] = None self.writer: Optional[SummaryWriter] = None self._fit_requirements: Optional[List[FitRequirement]] = [ FitRequirement("lr_scheduler", (_LRScheduler, ), user_defined=False, dataset_property=False), FitRequirement("num_run", (int, ), user_defined=False, dataset_property=False), FitRequirement("optimizer", (Optimizer, ), user_defined=False, dataset_property=False), FitRequirement("train_data_loader", (torch.utils.data.DataLoader, ), user_defined=False, dataset_property=False), FitRequirement("val_data_loader", (torch.utils.data.DataLoader, ), user_defined=False, dataset_property=False) ] self.checkpoint_dir: Optional[str] = None
def __init__(self, batch_size: int = 64, random_state: Optional[np.random.RandomState] = None) -> None: super().__init__(random_state=random_state) self.batch_size = batch_size self.train_data_loader: Optional[torch.utils.data.DataLoader] = None self.val_data_loader: Optional[torch.utils.data.DataLoader] = None self.test_data_loader: Optional[torch.utils.data.DataLoader] = None # We also support existing datasets! self.dataset = None self.vision_datasets = self.get_torchvision_datasets() # Save the transformations for reuse self.train_transform: Optional[torchvision.transforms.Compose] = None # The only reason we have val/test transform separated is to speed up # prediction during training. Namely, if is_small_preprocess is set to true # X_train data will be pre-processed, so we do no need preprocessing in the transform # Regardless, test/inference always need this transformation self.val_transform: Optional[torchvision.transforms.Compose] = None self.test_transform: Optional[torchvision.transforms.Compose] = None # Define fit requirements self.add_fit_requirements([ FitRequirement("split_id", (int,), user_defined=True, dataset_property=False), FitRequirement("Backend", (Backend,), user_defined=True, dataset_property=False), FitRequirement("is_small_preprocess", (bool,), user_defined=True, dataset_property=True)])
def __init__(self, random_state: Optional[Union[np.random.RandomState, int]] = None): super().__init__() self.random_state = random_state self.preprocessor: Optional[ColumnTransformer] = None self.add_fit_requirements([ FitRequirement('numerical_columns', (List,), user_defined=True, dataset_property=True), FitRequirement('categorical_columns', (List,), user_defined=True, dataset_property=True)])
def __init__(self) -> None: super().__init__() self.add_fit_requirements([ FitRequirement('X_train', (np.ndarray, pd.DataFrame, csr_matrix), user_defined=True, dataset_property=False), FitRequirement('backend', (Backend, ), user_defined=True, dataset_property=False)])
def __init__(self, percent: float = 0.1, random_state: Optional[Union[int, np.random.RandomState]] = None): super().__init__() self.random_state = random_state self.percent = percent self.pad_augmenter: Optional[Augmenter] = None self.crop_augmenter: Optional[Augmenter] = None self.add_fit_requirements([ FitRequirement('image_height', (int,), user_defined=True, dataset_property=True), FitRequirement('image_width', (int,), user_defined=True, dataset_property=True)])
def __init__(self) -> None: super().__init__() self.add_fit_requirements([ FitRequirement('numerical_columns', (List, ), user_defined=True, dataset_property=True), FitRequirement('categorical_columns', (List, ), user_defined=True, dataset_property=True) ])
def __init__(self) -> None: super(BaseNormalizer, self).__init__() self.add_fit_requirements([ FitRequirement('mean', (np.ndarray, ), user_defined=True, dataset_property=True), FitRequirement('std', (np.ndarray, ), user_defined=True, dataset_property=True) ])
def __init__(self, random_state: Optional[np.random.RandomState] = None) -> None: super().__init__() self.random_state = random_state self.add_fit_requirements([ FitRequirement('is_small_preprocess', (bool, ), user_defined=True, dataset_property=True), FitRequirement('X_train', (np.ndarray, pd.DataFrame, csr_matrix), user_defined=True, dataset_property=False) ])
def __init__(self, use_augmenter: bool = True, random_state: Optional[Union[int, np.random.RandomState]] = None): super().__init__(use_augmenter=use_augmenter) self.random_state = random_state self.add_fit_requirements([ FitRequirement('image_height', (int, ), user_defined=True, dataset_property=True), FitRequirement('image_width', (int, ), user_defined=True, dataset_property=True) ])
def __init__(self, **kwargs: Any): super().__init__() self.add_fit_requirements([ FitRequirement('input_shape', (Iterable, ), user_defined=True, dataset_property=True), FitRequirement('task_type', (str, ), user_defined=True, dataset_property=True), FitRequirement('output_shape', (Iterable, int), user_defined=True, dataset_property=True), ]) self.head: nn.Module = None self.config = kwargs
def __init__(self) -> None: super().__init__() self.optimizer: Optional[Optimizer] = None self.add_fit_requirements([ FitRequirement('network', (torch.nn.Module, ), user_defined=False, dataset_property=False) ])
def __init__(self) -> None: super().__init__() self.scheduler = None # type: Optional[_LRScheduler] self.add_fit_requirements([ FitRequirement('optimizer', (Optimizer, ), user_defined=False, dataset_property=False) ])
def __init__(self, network: Optional[torch.nn.Module] = None, random_state: Optional[np.random.RandomState] = None) -> None: super(NetworkComponent, self).__init__() self.random_state = random_state self.device = None self.add_fit_requirements([ FitRequirement("network_head", (torch.nn.Module, ), user_defined=False, dataset_property=False), FitRequirement("network_backbone", (torch.nn.Module, ), user_defined=False, dataset_property=False), FitRequirement("network_embedding", (torch.nn.Module, ), user_defined=False, dataset_property=False), ]) self.network = network self.final_activation: Optional[torch.nn.Module] = None
def __init__(self, dataset_properties: Dict[str, Any], random_state: Optional[np.random.RandomState] = None ): super().__init__(dataset_properties=dataset_properties, random_state=random_state) self.run_summary = None # type: Optional[RunSummary] self.writer = None # type: Optional[SummaryWriter] self._fit_requirements: Optional[List[FitRequirement]] = [ FitRequirement("lr_scheduler", (_LRScheduler,), user_defined=False, dataset_property=False), FitRequirement("network", (torch.nn.Sequential,), user_defined=False, dataset_property=False), FitRequirement( "optimizer", (Optimizer,), user_defined=False, dataset_property=False), FitRequirement("train_data_loader", (torch.utils.data.DataLoader,), user_defined=False, dataset_property=False), FitRequirement("val_data_loader", (torch.utils.data.DataLoader,), user_defined=False, dataset_property=False)]
def __init__( self, random_state: Optional[np.random.RandomState] = None, model: Optional[BaseTraditionalLearner] = None, device: Optional[torch.device] = None ) -> None: super(BaseModelComponent, self).__init__() if random_state is None: self.random_state = check_random_state(1) else: self.random_state = check_random_state(random_state) self.fit_output: Dict[str, Any] = dict() self.model: Optional[BaseTraditionalLearner] = model self.add_fit_requirements([ FitRequirement('X_train', (np.ndarray, list, pd.DataFrame), user_defined=False, dataset_property=False), FitRequirement('y_train', (np.ndarray, list, pd.Series,), user_defined=False, dataset_property=False), FitRequirement('train_indices', (np.ndarray, list), user_defined=False, dataset_property=False), FitRequirement('val_indices', (np.ndarray, list), user_defined=False, dataset_property=False)])
def __init__(self, **kwargs: Any): super().__init__() self.add_fit_requirements([ FitRequirement('is_small_preprocess', (bool, ), user_defined=True, dataset_property=True), FitRequirement('X_train', (np.ndarray, pd.DataFrame, csr_matrix), user_defined=True, dataset_property=False), FitRequirement('input_shape', (Iterable, ), user_defined=True, dataset_property=True), FitRequirement('tabular_transformer', (BaseEstimator, ), user_defined=False, dataset_property=False), FitRequirement('network_embedding', (nn.Module, ), user_defined=False, dataset_property=False) ]) self.backbone: nn.Module = None self.config = kwargs self.input_shape: Optional[Iterable] = None
def __init__( self, bias_strategy: str, random_state: Optional[np.random.RandomState] = None, ) -> None: super().__init__() self.bias_strategy = bias_strategy self.random_state = random_state self.add_fit_requirements([ FitRequirement('network', (torch.nn.Module, ), user_defined=False, dataset_property=False) ])
def __init__(self, step_interval: Union[str, StepIntervalUnit]): super().__init__() self.scheduler: Optional[_LRScheduler] = None self._step_interval: StepIntervalUnit if isinstance(step_interval, str): if step_interval not in StepIntervalUnitChoices: raise ValueError('step_interval must be either {}, but got {}.'.format( StepIntervalUnitChoices, step_interval )) self._step_interval = getattr(StepIntervalUnit, step_interval) else: self._step_interval = step_interval self.add_fit_requirements([ FitRequirement('optimizer', (Optimizer,), user_defined=False, dataset_property=False)])
def __init__(self, n_components: int = 10, kernel: str = 'rbf', degree: int = 3, gamma: float = 0.01, coef0: float = 0.0, random_state: Optional[np.random.RandomState] = None): self.n_components = n_components self.kernel = kernel self.degree = degree self.gamma = gamma self.coef0 = coef0 super().__init__(random_state=random_state) self.add_fit_requirements([ FitRequirement('issparse', (bool, ), user_defined=True, dataset_property=True) ])