Skip to content

Commit eed5954

Browse files
author
Lucas Zimmer
committed
Added infos for config options
1 parent 79bce9a commit eed5954

File tree

13 files changed

+582
-388
lines changed

13 files changed

+582
-388
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ test_predictions_for_ensemble.npy
4545

4646
# testing
4747
tests.ipynb
48+
49+
# venv
50+
env/

autoPyTorch/components/networks/image/mobilenet.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ def _cfg(url='', **kwargs):
194194

195195
self.model.default_cfg = _cfg(url='', input_size=in_features, pool_size=(10, 10), crop_pct=0.904, num_classes=out_features)
196196

197-
self.layers = nn.Sequential(self.model.forward_features)
198-
199197
def forward(self, x):
200198
# make sure channels first
201199
x = self.model(x)

autoPyTorch/components/training/image/trainer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def train(self, epoch, train_loader, metrics):
6969
metric_results = [0] * len(metrics)
7070
start_time = time.time()
7171
for step, (data, targets) in enumerate(train_loader):
72-
7372
# import matplotlib.pyplot as plt
7473
# img = plt.imshow(data.numpy()[0,1,:])
7574
# plt.show()
@@ -125,6 +124,8 @@ def train(self, epoch, train_loader, metrics):
125124
budget_exceeded = True
126125
break
127126

127+
if N==0: # Fixes a bug during initialization
128+
N=1
128129

129130
if self.images_plot_count > 0:
130131
import tensorboard_logger as tl

autoPyTorch/core/api.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,24 @@ def score(self, X_test, Y_test, return_loss_value=False):
269269
return metric(torch.from_numpy(Y_pred.astype(np.float32)), torch.from_numpy(Y_test.astype(np.float32)))
270270

271271
def get_pytorch_model(self):
272-
"""Returns a pytorch sequential model of the current incumbent configuration
272+
"""Returns a pytorch sequential model of the current incumbent configuration. Not possible for all models.
273273
274274
Arguments:
275275
276276
Returns:
277277
model -- PyTorch sequential model of the current incumbent configuration
278278
"""
279-
if NetworkSelector.get_name() in self.pipeline:
280-
return self.pipeline[NetworkSelector.get_name()].fit_output["network"].layers
281-
else:
282-
return self.pipeline[NetworkSelectorDatasetInfo.get_name()].fit_output["network"].layers
279+
try:
280+
if NetworkSelector.get_name() in self.pipeline:
281+
return self.pipeline[NetworkSelector.get_name()].fit_output["network"].layers
282+
else:
283+
return self.pipeline[NetworkSelectorDatasetInfo.get_name()].fit_output["network"].layers
284+
except:
285+
print("Can not get PyTorch Sequential model for incumbent config. Returning Auto-PyTorch model")
286+
if NetworkSelector.get_name() in self.pipeline:
287+
return self.pipeline[NetworkSelector.get_name()].fit_output["network"]
288+
else:
289+
return self.pipeline[NetworkSelectorDatasetInfo.get_name()].fit_output["network"]
283290

284291
def initialize_from_checkpoint(self, hyperparameter_config, checkpoint, in_features, out_features, final_activation=None):
285292
"""

autoPyTorch/pipeline/nodes/image/create_dataset_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def predict(self, pipeline_config, X):
7777
def get_pipeline_config_options(self):
7878
options = [
7979
ConfigOption(name="file_extensions", default=['.png', '.jpg', '.JPEG', '.pgm'], type=str, list=True),
80-
ConfigOption(name="images_shape", default=[3, 32, 32], type=int, list=True),
81-
ConfigOption(name="images_root_folders", default=[ConfigFileParser.get_autonet_home()], type='directory', list=True),
80+
ConfigOption(name="images_shape", default=[3, 32, 32], type=int, list=True, info="Image size input to the networks, images will be rescaled to this."),
81+
ConfigOption(name="images_root_folders", default=[ConfigFileParser.get_autonet_home()], type='directory', list=True, info="Directory relative to which image paths are given."),
8282
ConfigOption(name="max_class_size", default=None, type=int),
8383
]
8484
return options

autoPyTorch/pipeline/nodes/image/create_image_dataloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def fit(self, pipeline_config, hyperparameter_config, X, Y, train_indices, valid
6363

6464
def get_pipeline_config_options(self):
6565
options = [
66-
ConfigOption("default_dataset_download_dir", default=ConfigFileParser.get_autonet_home(), type='directory'),
66+
ConfigOption("default_dataset_download_dir", default=ConfigFileParser.get_autonet_home(), type='directory', info="Directory default datasets will be downloaded to."),
6767
ConfigOption("dataloader_worker", default=1, type=int),
6868
ConfigOption("dataloader_cache_size_mb", default=0, type=int)
6969
]

autoPyTorch/pipeline/nodes/image/image_augmentation.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,12 @@ def compute_mean_std(self, pipeline_config, hyperparameter_config, X, Y, train_i
210210
std = std + data.std(2).sum(0)
211211
nb_samples += batch_samples
212212

213-
mean /= nb_samples
214-
std /= nb_samples
215-
216-
mean, std = mean.numpy().tolist(), std.numpy().tolist()
213+
if nb_samples > 0.:
214+
mean /= nb_samples
215+
std /= nb_samples
216+
mean, std = mean.numpy().tolist(), std.numpy().tolist()
217+
else:
218+
mean, std = [mean], [std]
217219

218220
log.debug('MEAN: ' + str(mean) + ' -- STD: ' + str(std))
219221

autoPyTorch/pipeline/nodes/image/multiple_datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def predict(self, pipeline_config, X):
107107

108108
def get_pipeline_config_options(self):
109109
options = [
110-
ConfigOption('dataset_order', default=None, type=int, list=True),
110+
ConfigOption('dataset_order', default=None, type=int, list=True, info="Order in which datasets are considered."),
111111

112112
#autonet.refit sets this to false to avoid refit budget issues
113-
ConfigOption('increase_number_of_trained_datasets', default=True, type=to_bool)
113+
ConfigOption('increase_number_of_trained_datasets', default=True, type=to_bool, info="Wether to increase the number of considered datasets with each successive halfing iteration.")
114114
]
115115
return options

autoPyTorch/pipeline/nodes/image/optimization_algorithm_no_timelimit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ def get_pipeline_config_options(self):
151151
ConfigOption("task_id", default=-1, type=int, info="ID for each worker, if you run AutoNet on a cluster. Set to -1, if you run it locally. "),
152152
ConfigOption("algorithm", default="bohb", type=str, choices=list(self.algorithms.keys())),
153153
ConfigOption("budget_type", default="time", type=str, choices=['time', 'epochs']),
154-
ConfigOption("min_budget", default=lambda c: 120 if c['budget_type'] == 'time' else 5, type=float, depends=True),
155-
ConfigOption("max_budget", default=lambda c: 6000 if c['budget_type'] == 'time' else 150, type=float, depends=True),
154+
ConfigOption("min_budget", default=lambda c: 120 if c['budget_type'] == 'time' else 5, type=float, depends=True, info="Min budget for fitting configurations."),
155+
ConfigOption("max_budget", default=lambda c: 6000 if c['budget_type'] == 'time' else 150, type=float, depends=True, info="Max budget for fitting configurations."),
156156
ConfigOption("max_runtime",
157157
default=lambda c: ((-int(np.log(c["min_budget"] / c["max_budget"]) / np.log(c["eta"])) + 1) * c["max_budget"])
158158
if c["budget_type"] == "time" else float("inf"),
159-
type=float, depends=True),
159+
type=float, depends=True, info="Total time for the run."),
160160
ConfigOption("num_iterations",
161161
default=lambda c: (-int(np.log(c["min_budget"] / c["max_budget"]) / np.log(c["eta"])) + 1)
162162
if c["budget_type"] == "epochs" else float("inf"),
163-
type=float, depends=True),
163+
type=float, depends=True, info="Number of successive halving iterations"),
164164
ConfigOption("eta", default=3, type=float, info='eta parameter of Hyperband.'),
165165
ConfigOption("min_workers", default=1, type=int),
166166
ConfigOption("working_dir", default=".", type="directory"),

autoPyTorch/pipeline/nodes/image/simple_train_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def get_pipeline_config_options(self):
295295
type=str, list=True, choices=list(self.batch_loss_computation_techniques.keys())),
296296
ConfigOption("minimize", default=self.default_minimize_value, type=to_bool, choices=[True, False]),
297297
ConfigOption("cuda", default=True, type=to_bool, choices=[True, False]),
298-
ConfigOption("save_checkpoints", default=False, type=to_bool, choices=[True, False]),
298+
ConfigOption("save_checkpoints", default=False, type=to_bool, choices=[True, False], info="Wether to save state dicts as checkpoints."),
299299
ConfigOption("tensorboard_min_log_interval", default=30, type=int),
300300
ConfigOption("tensorboard_images_count", default=0, type=int),
301301
ConfigOption("evaluate_on_train_data", default=True, type=to_bool),

0 commit comments

Comments
 (0)