Expand description
Neural Architecture Search (NAS) for TensorLogic.
This module provides infrastructure for automatically discovering high-performing
neural network architectures without manual design. The search follows the
ask/tell convention used throughout this crate: callers request a candidate
architecture via ask(), evaluate it externally, then report the score via
tell(). No objective closure is stored.
§Algorithms
| Type | Struct | Notes |
|---|---|---|
| Random search | RandomArchSearch | Uniform baseline, no state |
| Regularized evolution | RegularizedEvolution | Real et al. 2019 1 |
§Regularized (Aging) Evolution
Based on Real et al. (2019) “Regularized Evolution for Image Classifier Architecture Search” (AAAI 2019, https://arxiv.org/abs/1802.01548).
The algorithm maintains a cyclic population of fixed size
(population_size). Once the population is full:
- Draw
tournament_sizemembers uniformly at random. - Select the highest-scoring member (the winner).
- Apply a single random mutation to the winner to produce a child.
- Evaluate the child externally (ask/tell cycle).
- Add the child to the population and evict the oldest member (front of the deque) — regardless of its score.
Aging pressure prevents premature convergence and keeps exploration alive throughout the search budget.
§Search Space
ArchSearchSpace constrains:
- Depth range (
min_depth..max_depth) - Per-layer width options (discrete set of
usize) - Per-layer activation options (e.g.
"relu","gelu","tanh") - Per-layer operation options (e.g.
"linear","conv","attention")
ArchSampler draws uniformly from this space and implements the four
mutation operators (change op, change width, change activation, add/remove
layer).
§Quick Start
use tensorlogic_train::nas::{ArchSearchSpace, RegularizedEvolution};
let space = ArchSearchSpace::new(
2, 6,
vec![64, 128, 256],
vec!["relu".to_string(), "gelu".to_string()],
vec!["linear".to_string(), "conv".to_string()],
).unwrap();
let mut evo = RegularizedEvolution::new(space, 20, 5, 42).unwrap();
for _ in 0..100 {
let arch = evo.ask().unwrap();
// …evaluate arch externally…
let score = 0.9_f64; // placeholder
evo.tell(arch, score);
}
if let Some((best, score)) = evo.best() {
println!("Best depth={}, score={score:.4}", best.depth());
}Real, E., Aggarwal, A., Huang, Y., & Le, Q. V. (2019). Regularized evolution for image classifier architecture search. Proceedings of the AAAI Conference on Artificial Intelligence, 33(01), 4780–4789. ↩
Re-exports§
pub use evolution::NasResult;pub use evolution::RegularizedEvolution;pub use random_search::RandomArchSearch;pub use sampler::ArchSampler;pub use space::ArchSearchSpace;pub use space::Architecture;pub use space::LayerSpec;
Modules§
- evolution
- Regularized (aging) evolution for neural architecture search.
- random_
search - Random architecture search for NAS.
- sampler
- Random architecture sampler and mutation operators for NAS.
- space
- Neural architecture search space definitions.