Skip to content

Commit d29d11b

Browse files
authored
[FIX] apply cutout for each row. (#481)
* fixed cut mix * remove unnecessary comment * change all_supported_metrics
1 parent 34c704d commit d29d11b

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

autoPyTorch/api/base_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ def _search(
978978
smac_scenario_args: Optional[Dict[str, Any]] = None,
979979
get_smac_object_callback: Optional[Callable] = None,
980980
tae_func: Optional[Callable] = None,
981-
all_supported_metrics: bool = True,
981+
all_supported_metrics: bool = False,
982982
precision: int = 32,
983983
disable_file_output: Optional[List[Union[str, DisableFileOutputParameters]]] = None,
984984
load_models: bool = True,
@@ -1076,7 +1076,7 @@ def _search(
10761076
TargetAlgorithm to be optimised. If None, `eval_function`
10771077
available in autoPyTorch/evaluation/train_evaluator is used.
10781078
Must be child class of AbstractEvaluator.
1079-
all_supported_metrics (bool: default=True):
1079+
all_supported_metrics (bool: default=False):
10801080
If True, all metrics supporting current task will be calculated
10811081
for each pipeline and results will be available via cv_results
10821082
precision (int: default=32):

autoPyTorch/api/tabular_classification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def search(
254254
memory_limit: int = 4096,
255255
smac_scenario_args: Optional[Dict[str, Any]] = None,
256256
get_smac_object_callback: Optional[Callable] = None,
257-
all_supported_metrics: bool = True,
257+
all_supported_metrics: bool = False,
258258
precision: int = 32,
259259
disable_file_output: Optional[List[Union[str, DisableFileOutputParameters]]] = None,
260260
load_models: bool = True,
@@ -354,7 +354,7 @@ def search(
354354
TargetAlgorithm to be optimised. If None, `eval_function`
355355
available in autoPyTorch/evaluation/train_evaluator is used.
356356
Must be child class of AbstractEvaluator.
357-
all_supported_metrics (bool: default=True):
357+
all_supported_metrics (bool: default=False):
358358
If True, all metrics supporting current task will be calculated
359359
for each pipeline and results will be available via cv_results
360360
precision (int: default=32):

autoPyTorch/api/tabular_regression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def search(
253253
memory_limit: int = 4096,
254254
smac_scenario_args: Optional[Dict[str, Any]] = None,
255255
get_smac_object_callback: Optional[Callable] = None,
256-
all_supported_metrics: bool = True,
256+
all_supported_metrics: bool = False,
257257
precision: int = 32,
258258
disable_file_output: Optional[List[Union[str, DisableFileOutputParameters]]] = None,
259259
load_models: bool = True,
@@ -353,7 +353,7 @@ def search(
353353
TargetAlgorithm to be optimised. If None, `eval_function`
354354
available in autoPyTorch/evaluation/train_evaluator is used.
355355
Must be child class of AbstractEvaluator.
356-
all_supported_metrics (bool: default=True):
356+
all_supported_metrics (bool: default=False):
357357
If True, all metrics supporting current task will be calculated
358358
for each pipeline and results will be available via cv_results
359359
precision (int: default=32):

autoPyTorch/api/time_series_forecasting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def search(
289289
memory_limit: Optional[int] = 4096,
290290
smac_scenario_args: Optional[Dict[str, Any]] = None,
291291
get_smac_object_callback: Optional[Callable] = None,
292-
all_supported_metrics: bool = True,
292+
all_supported_metrics: bool = False,
293293
precision: int = 32,
294294
disable_file_output: List = [],
295295
load_models: bool = True,
@@ -396,7 +396,7 @@ def search(
396396
instances, num_params, runhistory, seed and ta. This is
397397
an advanced feature. Use only if you are familiar with
398398
[SMAC](https://automl.github.io/SMAC3/master/index.html).
399-
all_supported_metrics (bool), (default=True): if True, all
399+
all_supported_metrics (bool), (default=False): if True, all
400400
metrics supporting current task will be calculated
401401
for each pipeline and results will be available via cv_results
402402
precision (int), (default=32): Numeric precision used when loading

autoPyTorch/pipeline/components/training/trainer/RowCutMixTrainer.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ def data_preparation(self, X: np.ndarray, y: np.ndarray,
3737
if beta <= 0 or r > self.alpha:
3838
return X, {'y_a': y, 'y_b': y[shuffled_indices], 'lam': 1}
3939

40-
cut_column_indices = torch.as_tensor(
41-
self.random_state.choice(
42-
range(n_columns),
43-
max(1, np.int32(n_columns * lam)),
44-
replace=False,
45-
),
46-
)
4740

4841
# Replace the values in `cut_indices` columns with
4942
# the values from `permed_indices`
50-
X[:, cut_column_indices] = X[shuffled_indices, :][:, cut_column_indices]
43+
for i, idx in enumerate(shuffled_indices):
44+
cut_column_indices = torch.as_tensor(
45+
self.random_state.choice(
46+
range(n_columns),
47+
max(1, np.int32(n_columns * lam)),
48+
replace=False,
49+
),
50+
)
51+
X[i, cut_column_indices] = X[idx, cut_column_indices]
5152

5253
# Since we cannot cut exactly `lam x 100 %` of rows, we need to adjust the `lam`
5354
lam = 1 - (len(cut_column_indices) / n_columns)

autoPyTorch/pipeline/components/training/trainer/RowCutOutTrainer.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ def data_preparation(self, X: np.ndarray, y: np.ndarray,
3939
lam = 1
4040
return X, {'y_a': y_a, 'y_b': y_b, 'lam': lam}
4141

42-
size: int = np.shape(X)[1]
43-
cut_column_indices = self.random_state.choice(
44-
range(size),
45-
max(1, np.int32(size * self.patch_ratio)),
46-
replace=False,
47-
)
42+
n_rows, size = np.shape(X)
43+
for i in range(n_rows):
44+
cut_column_indices = self.random_state.choice(
45+
range(size),
46+
max(1, np.int32(size * self.patch_ratio)),
47+
replace=False,
48+
)
49+
X[i, cut_column_indices] = 0
50+
4851

4952
# Mask the selected features as 0
50-
X[:, cut_column_indices] = 0
5153
lam = 1
5254
y_a = y
5355
y_b = y

0 commit comments

Comments
 (0)