spotoptim 3.3.0__tar.gz → 3.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spotoptim-3.3.0 → spotoptim-3.3.1}/PKG-INFO +1 -1
- {spotoptim-3.3.0 → spotoptim-3.3.1}/pyproject.toml +1 -1
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/torch_objective.py +20 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/nn/linear_regressor.py +13 -2
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/mapping.py +5 -1
- {spotoptim-3.3.0 → spotoptim-3.3.1}/README.md +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/SpotOptim.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/core/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/core/data.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/core/experiment.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/core/protocol.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/core/storage.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/data/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/data/base.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/data/diabetes.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/data/manydataset.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/datasets/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/datasets/py.typed +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/datasets/test01.csv +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/datasets/test02.csv +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/datasets/test11.csv +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/eda/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/eda/plots.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/confirmatory_factor_analyzer.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/factor_analyzer.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/factor_analyzer_rotator.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/factor_analyzer_utils.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/cd_data.csv +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/forr08a.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/mo.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/remote.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/sequence_cv_objective.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/function/so.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/hyperparameters/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/hyperparameters/parameters.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/hyperparameters/repr_helpers.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/inspection/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/inspection/importance.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/inspection/predictions.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/mo/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/mo/mo_mm.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/mo/pareto.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/nn/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/nn/many_to_many_rnn.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/nn/mlp.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/nn/optimizer.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/nn/training.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/optimizer/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/optimizer/acquisition.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/optimizer/schedule_free.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/optimizer/wrapper.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/plot/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/plot/contour.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/plot/mo.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/plot/visualization.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/py.typed +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/reporting/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/reporting/analysis.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/reporting/results.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/sampling/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/sampling/design.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/sampling/effects.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/sampling/lhs.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/sampling/mm.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/kernels.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/kriging.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/mlp_surrogate.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/nystroem.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/pipeline.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/surrogate/simple_kriging.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/tricands/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/tricands/tricands.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/__init__.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/boundaries.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/convert.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/dimreduction.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/eval.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/file.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/ocba.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/pca.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/scaler.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/seed.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/serialization.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/stats.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/tensorboard.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/transform.py +0 -0
- {spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/utils/variables.py +0 -0
|
@@ -369,6 +369,10 @@ class TorchObjective:
|
|
|
369
369
|
|
|
370
370
|
Executes the training loop for the specified number of epochs. Handles optimizer
|
|
371
371
|
creation, loss calculation, backward pass, and validation evaluation.
|
|
372
|
+
Schedule-free optimizers (those exposing ``train()``/``eval()``, e.g.
|
|
373
|
+
``AdamWScheduleFree``) are switched to training mode before each epoch and to
|
|
374
|
+
evaluation mode before validation, so validation metrics are computed on the
|
|
375
|
+
averaged parameters; the optimizer is left in evaluation mode on return.
|
|
372
376
|
|
|
373
377
|
Args:
|
|
374
378
|
model (nn.Module): The PyTorch model to train.
|
|
@@ -438,8 +442,17 @@ class TorchObjective:
|
|
|
438
442
|
# For now, we train for exact 'epochs'
|
|
439
443
|
trained_epochs = epochs
|
|
440
444
|
|
|
445
|
+
# Schedule-free optimizers (e.g. AdamWScheduleFree) keep the training
|
|
446
|
+
# iterate and the averaged parameters separate; they require
|
|
447
|
+
# optimizer.train()/optimizer.eval() around the respective phases so
|
|
448
|
+
# that validation sees the averaged weights.
|
|
449
|
+
optimizer_train = getattr(optimizer, "train", None)
|
|
450
|
+
optimizer_eval = getattr(optimizer, "eval", None)
|
|
451
|
+
|
|
441
452
|
for epoch in range(epochs):
|
|
442
453
|
model.train()
|
|
454
|
+
if callable(optimizer_train):
|
|
455
|
+
optimizer_train()
|
|
443
456
|
train_loss = 0.0
|
|
444
457
|
steps = 0
|
|
445
458
|
for X_batch, y_batch in train_loader:
|
|
@@ -459,6 +472,8 @@ class TorchObjective:
|
|
|
459
472
|
# Validation
|
|
460
473
|
if val_loader:
|
|
461
474
|
model.eval()
|
|
475
|
+
if callable(optimizer_eval):
|
|
476
|
+
optimizer_eval()
|
|
462
477
|
val_loss = 0.0
|
|
463
478
|
val_steps = 0
|
|
464
479
|
with torch.no_grad():
|
|
@@ -481,6 +496,11 @@ class TorchObjective:
|
|
|
481
496
|
if final_train_loss < min_val_loss:
|
|
482
497
|
min_val_loss = final_train_loss
|
|
483
498
|
|
|
499
|
+
# Leave schedule-free optimizers in eval mode so the model holds the
|
|
500
|
+
# averaged parameters for any downstream use.
|
|
501
|
+
if callable(optimizer_eval):
|
|
502
|
+
optimizer_eval()
|
|
503
|
+
|
|
484
504
|
# Collect metrics
|
|
485
505
|
metrics_out = {}
|
|
486
506
|
|
|
@@ -296,8 +296,9 @@ class LinearRegressor(nn.Module):
|
|
|
296
296
|
Args:
|
|
297
297
|
optimizer_name (str, optional): Name of the optimizer from torch.optim.
|
|
298
298
|
Common options: "Adam", "AdamW", "Adamax", "SGD", "RMSprop", "Adagrad",
|
|
299
|
-
"Adadelta", "NAdam", "RAdam", "ASGD", "LBFGS", "Rprop".
|
|
300
|
-
|
|
299
|
+
"Adadelta", "NAdam", "RAdam", "ASGD", "LBFGS", "Rprop". The vendored
|
|
300
|
+
schedule-free "AdamWScheduleFree" (spotoptim.optimizer) is also
|
|
301
|
+
supported. Defaults to "Adam".
|
|
301
302
|
lr (float, optional): Unified learning rate multiplier. If None, uses self.lr.
|
|
302
303
|
This value is automatically scaled to optimizer-specific learning rates.
|
|
303
304
|
A value of 1.0 corresponds to the optimizer's default learning rate.
|
|
@@ -467,6 +468,16 @@ class LinearRegressor(nn.Module):
|
|
|
467
468
|
optimizer_class = getattr(optim, optimizer_name)
|
|
468
469
|
# Create optimizer with model parameters, mapped learning rate, and additional kwargs
|
|
469
470
|
return optimizer_class(self.parameters(), lr=lr_actual, **kwargs)
|
|
471
|
+
|
|
472
|
+
# Check for custom schedule-free optimizer
|
|
473
|
+
elif optimizer_name == "AdamWScheduleFree":
|
|
474
|
+
try:
|
|
475
|
+
from spotoptim.optimizer import AdamWScheduleFree
|
|
476
|
+
|
|
477
|
+
return AdamWScheduleFree(self.parameters(), lr=lr_actual, **kwargs)
|
|
478
|
+
except ImportError as e:
|
|
479
|
+
raise ImportError(f"Could not import AdamWScheduleFree: {e}")
|
|
480
|
+
|
|
470
481
|
else:
|
|
471
482
|
raise ValueError(
|
|
472
483
|
f"Optimizer '{optimizer_name}' not found in torch.optim. "
|
|
@@ -27,6 +27,8 @@ OPTIMIZER_DEFAULT_LR: Dict[str, float] = {
|
|
|
27
27
|
"RMSprop": 0.01,
|
|
28
28
|
"Rprop": 0.01,
|
|
29
29
|
"SGD": 0.01,
|
|
30
|
+
# spotoptim's vendored schedule-free optimizer (spotoptim.optimizer)
|
|
31
|
+
"AdamWScheduleFree": 0.0025,
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
|
|
@@ -49,7 +51,9 @@ def map_lr(
|
|
|
49
51
|
rate, values > 1.0 increase it. Typical range: [0.001, 100.0].
|
|
50
52
|
optimizer_name (str): Name of the PyTorch optimizer. Must be one of:
|
|
51
53
|
"Adadelta", "Adagrad", "Adam", "AdamW", "SparseAdam", "Adamax",
|
|
52
|
-
"ASGD", "LBFGS", "NAdam", "RAdam", "RMSprop", "Rprop", "SGD"
|
|
54
|
+
"ASGD", "LBFGS", "NAdam", "RAdam", "RMSprop", "Rprop", "SGD",
|
|
55
|
+
"AdamWScheduleFree" (spotoptim's vendored schedule-free optimizer,
|
|
56
|
+
default lr 0.0025).
|
|
53
57
|
use_default_scale (bool, optional): Whether to scale by the optimizer's default
|
|
54
58
|
learning rate. If True (default), lr_unified is multiplied by the default
|
|
55
59
|
lr. If False, returns lr_unified directly. Defaults to True.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/confirmatory_factor_analyzer.py
RENAMED
|
File without changes
|
|
File without changes
|
{spotoptim-3.3.0 → spotoptim-3.3.1}/src/spotoptim/factor_analyzer/factor_analyzer_rotator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|