Enumerate Grid-Search Hyperparameter Combinations and Manage Explosion
Context
You are building a hyper-parameter optimization service that must enumerate every grid-search combination. The input is a Python dict mapping parameter names to candidate values, e.g.,
-
{'learning_rate': [0.1, 0.2], 'feature': ['A', 'B'], 'batch': [10, 20]}
Tasks
-
Write a Python generator that lazily yields all combinations as dicts (memory efficient, supports any number of parameters).
-
Briefly discuss practical alternatives to avoid combinatorial explosion when grids are huge.
Notes
-
You may use recursive backtracking or itertools.product.
-
Mention strategies such as random search, Bayesian optimization, and Sobol/low-discrepancy sampling.