Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
research-artifacts
machine-learning
continual-learning
neural-plasticity
meta-learning
evolvability
License:
Download research/v2/src/controller.py from PureOne/evolvability-preserving-dormant-dendrites: direct link, hf CLI and curl.
- Browser
- Download file 1.98 kB
-
https://huggingface.co/datasets/PureOne/evolvability-preserving-dormant-dendrites/resolve/main/research/v2/src/controller.py
- Command line
-
hf download hf://datasets/PureOne/evolvability-preserving-dormant-dendrites/research/v2/src/controller.py
-
curl -L -o controller.py https://huggingface.co/datasets/PureOne/evolvability-preserving-dormant-dendrites/resolve/main/research/v2/src/controller.py
1.98 kB
| """Finite-candidate admission only. No automatic claim of a global neural controller.""" | |
| from dataclasses import dataclass | |
| import numpy as np | |
| from .joint import witness_scores, witness_radius | |
| class Candidate: | |
| name: str | |
| K: np.ndarray | |
| predictions: np.ndarray | |
| incremental_price: float | |
| feasible: bool = True | |
| def select_candidate(residuals, baseline_K, baseline_predictions, candidates, | |
| R_bound, M_bound, delta=.05, eta=1.): | |
| """Requires candidates fixed before an independent bounded evaluation batch. | |
| Prices must already include every incremental resource and opportunity cost. | |
| Returns a conservative candidate or None, plus the complete score audit. | |
| """ | |
| residuals=np.asarray(residuals) | |
| all_predictions=[baseline_predictions]+[c.predictions for c in candidates] | |
| if np.max(np.linalg.norm(residuals,axis=1))>R_bound+1e-12: | |
| raise ValueError('residual bound violated; no bounded-data certificate') | |
| if any(np.max(np.linalg.norm(p,axis=1))>M_bound+1e-12 for p in all_predictions): | |
| raise ValueError('prediction bound violated') | |
| eps=witness_radius(len(residuals),len(candidates)+1,R_bound,M_bound,delta) | |
| base=float(witness_scores(residuals,baseline_predictions,baseline_K,eta).mean()) | |
| audit=[];best=None;best_lcb=0. | |
| for candidate in candidates: | |
| score=float(witness_scores(residuals,candidate.predictions,candidate.K,eta).mean()) | |
| lcb=score-base-candidate.incremental_price-2*eps | |
| audit.append(dict(name=candidate.name,empirical_gain=score-base, | |
| price=candidate.incremental_price,net_lower_bound=lcb, | |
| feasible=candidate.feasible)) | |
| if candidate.feasible and lcb>best_lcb: | |
| best,best_lcb=candidate.name,lcb | |
| return best,dict(baseline=base,per_candidate_radius=eps,candidates=audit, | |
| assumptions='independent bounded samples; designs fixed before evaluation') | |