Skip to content

Commit e178f78

Browse files
committed
Add backup.
1 parent c943d88 commit e178f78

60 files changed

Lines changed: 16793 additions & 779 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

run_new_tests.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ def run_all_new_tests(verbose: bool = False) -> Dict[str, Any]:
9292
'tests/test_adaptive_episode_sampler.py',
9393
'tests/test_curriculum_sampler.py',
9494
'tests/test_omniglot_dataset.py',
95-
'tests/test_integration_workflow.py'
95+
'tests/test_integration_workflow.py',
96+
'tests/test_phase4_ml_enhancements.py',
97+
'tests/test_error_handling_comprehensive.py',
98+
'tests/test_evaluation_comprehensive.py',
99+
'tests/test_research_patches_determinism.py',
100+
'tests/test_performance_benchmarking.py'
96101
]
97102

98103
results = []
@@ -145,6 +150,11 @@ def run_all_new_tests(verbose: bool = False) -> Dict[str, Any]:
145150
print("✅ CurriculumSampler operational")
146151
print("✅ OmniglotDataset implemented")
147152
print("✅ Complete workflow integration successful")
153+
print("✅ Phase 4 ML-powered enhancements functional")
154+
print("✅ Error handling and recovery mechanisms working")
155+
print("✅ Evaluation harness and metrics operational")
156+
print("✅ Research patches and determinism validated")
157+
print("✅ Performance benchmarking comprehensive")
148158
else:
149159
print(f"\n💥 {failed} test file(s) failed - see details above")
150160

@@ -171,6 +181,11 @@ def main():
171181
print(" - CurriculumSampler for progressive learning")
172182
print(" - OmniglotDataset implementation")
173183
print(" - Complete workflow integration tests")
184+
print(" - Phase 4 ML-powered enhancement components")
185+
print(" - Error handling and recovery mechanisms")
186+
print(" - Evaluation harness and metrics")
187+
print(" - Research patches and determinism hooks")
188+
print(" - Performance benchmarking and scalability")
174189
print()
175190
print("Options:")
176191
print(" --verbose, -v Show detailed test output")

src/meta_learning/__init__.py

Lines changed: 26 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -32,229 +32,61 @@
3232

3333
from ._version import __version__
3434

35-
# Core components - always available
35+
# Core essential components that should always work
3636
from .shared.types import Episode
3737
from .core.utils import partition_task, remap_labels
3838
from .core.seed import seed_all
39-
from .core.bn_policy import freeze_batchnorm_running_stats
4039
from .core.math_utils import pairwise_sqeuclidean, cosine_logits
4140

42-
# Data handling - essential utilities
41+
# Essential data utilities
4342
from .data_utils import InfiniteIterator, OnDeviceDataset
44-
from .data import SyntheticFewShotDataset, CIFARFSDataset, MiniImageNetDataset, make_episodes
4543

46-
# Models - import conditionally to prevent crashes
47-
try:
48-
from .models.conv4 import Conv4
49-
CONV4_AVAILABLE = True
50-
except ImportError:
51-
Conv4 = None
52-
CONV4_AVAILABLE = False
44+
# Model architectures - recently implemented and tested
45+
from .models.conv4 import Conv4, ResNet12, WideResNet, MetaModule, MetaLinear, MetaConv2d
5346

54-
# Algorithms - now with integrated advanced features
55-
from .algos.protonet import ProtoHead # Now includes uncertainty estimation
56-
from .algos.maml import inner_adapt_and_eval, meta_outer_step, ContinualMAML
47+
# Basic algorithms
48+
from .algos.protonet import ProtoHead
49+
from .algos.maml import inner_adapt_and_eval, meta_outer_step
5750

5851
# Evaluation
5952
from .eval import evaluate
6053

6154
# Benchmarking
6255
from .bench import run_benchmark
6356

64-
65-
# Hardware acceleration and research integrity (imported separately for CLI)
66-
try:
67-
from .hardware_utils import (
68-
HardwareConfig, HardwareDetector, MemoryManager, ModelOptimizer,
69-
HardwareProfiler, create_hardware_config, setup_optimal_hardware
70-
)
71-
from .leakage_guard import (
72-
LeakageGuard, LeakageType, LeakageViolation, create_leakage_guard
73-
)
74-
INTEGRATED_ADVANCED_AVAILABLE = True
75-
except ImportError:
76-
INTEGRATED_ADVANCED_AVAILABLE = False
77-
78-
# Legacy standalone modules (for backward compatibility)
79-
try:
80-
from .continual_meta_learning import (
81-
OnlineMetaLearner, ContinualMetaConfig, FisherInformationMatrix,
82-
EpisodicMemoryBank, create_continual_meta_learner
83-
)
84-
from .few_shot_modules.uncertainty_components import (
85-
UncertaintyAwareDistance, MonteCarloDropout, DeepEnsemble,
86-
EvidentialLearning, UncertaintyConfig, create_uncertainty_aware_distance
87-
)
88-
STANDALONE_MODULES_AVAILABLE = True
89-
except ImportError:
90-
STANDALONE_MODULES_AVAILABLE = False
91-
92-
try:
93-
# Basic
94-
from .algorithms.ttc_scaler import TestTimeComputeScaler
95-
from .algorithms.ttc_config import TestTimeComputeConfig
96-
from .algorithms.maml_research_accurate import ResearchMAML, MAMLConfig, MAMLVariant
97-
98-
# Import research patches
99-
from .research_patches.batch_norm_policy import apply_episodic_bn_policy, EpisodicBatchNormPolicy
100-
from .research_patches.determinism_hooks import setup_deterministic_environment, DeterminismManager
101-
102-
# Import evaluation harness
103-
from .evaluation.few_shot_evaluation_harness import FewShotEvaluationHarness
104-
105-
# External research features available
106-
EXTERNAL_RESEARCH_AVAILABLE = True
107-
108-
except ImportError as e:
109-
# External research modules not available - core restored functionality still works!
110-
import warnings
111-
warnings.warn(f"External research modules not available: {e}. Core restored functionality still available!")
112-
113-
TestTimeComputeScaler = None
114-
TestTimeComputeConfig = None
115-
ResearchMAML = None
116-
MAMLConfig = None
117-
MAMLVariant = None
118-
apply_episodic_bn_policy = None
119-
EpisodicBatchNormPolicy = None
120-
setup_deterministic_environment = None
121-
DeterminismManager = None
122-
FewShotEvaluationHarness = None
123-
EXTERNAL_RESEARCH_AVAILABLE = False
124-
125-
# Core restored functionality is ALWAYS available now
126-
RESEARCH_AVAILABLE = True
127-
128-
# Input validation and error handling (newly implemented)
57+
# Core validation functionality
12958
from .validation import (
13059
ValidationError, ConfigurationWarning, validate_episode_tensors,
13160
validate_few_shot_configuration, validate_distance_metric,
132-
validate_temperature_parameter, validate_learning_rate,
133-
validate_model_parameters, validate_maml_config, validate_uncertainty_config,
134-
validate_optimizer_config, validate_episodic_config, validate_regularization_config,
135-
validate_complete_config, ValidationContext, check_episode_quality
136-
)
137-
138-
# Error recovery and fault tolerance (newly implemented)
139-
from .error_recovery import (
140-
RecoveryError, ErrorRecoveryManager, with_retry, safe_tensor_operation,
141-
handle_numerical_instability, recover_from_dimension_mismatch,
142-
RobustPrototypeNetwork, create_robust_episode, FaultTolerantTrainer, safe_evaluate
61+
validate_temperature_parameter, validate_learning_rate
14362
)
144-
from .core.seed import ReproducibilityManager, distributed_seed_sync, benchmark_reproducibility_overhead, validate_seed_effectiveness
145-
from .core.bn_policy import apply_episodic_bn_policy, validate_bn_compatibility, EpisodicBatchNormPolicy
146-
from .algos.ttcs import TTCSWarningSystem, ttcs_with_fallback, ttcs_for_learn2learn_models, TTCSProfiler
147-
148-
# High-level toolkit API - core component, should always work
149-
from .toolkit import MetaLearningToolkit, create_meta_learning_toolkit, quick_evaluation
150-
151-
# Dataset ecosystem - newly implemented
152-
try:
153-
from .data_utils.datasets import (
154-
BenchmarkDatasetManager, OnDeviceDataset, InfiniteEpisodeIterator,
155-
MiniImageNetDataset, SyntheticFewShotDataset, DatasetRegistry,
156-
BaseMetaLearningDataset
157-
)
158-
DATASET_ECOSYSTEM_AVAILABLE = True
159-
except ImportError:
160-
BenchmarkDatasetManager = None
161-
OnDeviceDataset = None
162-
InfiniteEpisodeIterator = None
163-
MiniImageNetDataset = None
164-
SyntheticFewShotDataset = None
165-
DatasetRegistry = None
166-
BaseMetaLearningDataset = None
167-
DATASET_ECOSYSTEM_AVAILABLE = False
168-
169-
# Error handling and monitoring - newly implemented
170-
try:
171-
from .error_handling import (
172-
IntelligentErrorRecovery, PerformanceMonitor, WarningManager,
173-
ErrorType, WarningCategory, with_error_recovery, monitor_performance
174-
)
175-
ERROR_HANDLING_AVAILABLE = True
176-
except ImportError:
177-
IntelligentErrorRecovery = None
178-
PerformanceMonitor = None
179-
WarningManager = None
180-
ErrorType = None
181-
WarningCategory = None
182-
with_error_recovery = None
183-
monitor_performance = None
184-
ERROR_HANDLING_AVAILABLE = False
18563

18664
__all__ = [
18765
"Episode",
18866
"remap_labels",
18967
"__version__",
19068
"partition_task",
69+
"seed_all",
70+
"pairwise_sqeuclidean",
71+
"cosine_logits",
19172
"InfiniteIterator",
19273
"OnDeviceDataset",
74+
"Conv4",
75+
"ResNet12",
76+
"WideResNet",
77+
"MetaModule",
78+
"MetaLinear",
79+
"MetaConv2d",
80+
"ProtoHead",
81+
"inner_adapt_and_eval",
82+
"meta_outer_step",
19383
"evaluate",
84+
"run_benchmark",
85+
"ValidationError",
86+
"ConfigurationWarning",
19487
"validate_episode_tensors",
19588
"validate_few_shot_configuration",
19689
"validate_distance_metric",
19790
"validate_temperature_parameter",
198-
"validate_learning_rate",
199-
"validate_model_parameters",
200-
"validate_maml_config",
201-
"validate_uncertainty_config",
202-
"validate_optimizer_config",
203-
"validate_episodic_config",
204-
"validate_regularization_config",
205-
"validate_complete_config",
206-
"validate_seed_effectiveness",
207-
"validate_bn_compatibility",
208-
"ValidationError",
209-
"RecoveryError",
210-
"ErrorRecoveryManager",
211-
"IntelligentErrorRecovery",
212-
"ErrorType",
213-
"with_error_recovery",
214-
"TestTimeComputeScaler",
215-
"TestTimeComputeConfig",
216-
"ResearchMAML",
217-
"MAMLConfig",
218-
"MAMLVariant",
219-
"setup_deterministic_environment",
220-
"DeterminismManager",
221-
"FewShotEvaluationHarness",
222-
"MetaLearningToolkit",
223-
"create_meta_learning_toolkit",
224-
"quick_evaluation",
225-
"RESEARCH_AVAILABLE",
226-
"EXTERNAL_RESEARCH_AVAILABLE",
227-
"DATASET_ECOSYSTEM_AVAILABLE",
228-
"ERROR_HANDLING_AVAILABLE",
229-
"ConfigurationWarning",
230-
"ValidationContext",
231-
"check_episode_quality",
232-
"with_retry",
233-
"safe_tensor_operation",
234-
"handle_numerical_instability",
235-
"recover_from_dimension_mismatch",
236-
"RobustPrototypeNetwork",
237-
"create_robust_episode",
238-
"FaultTolerantTrainer",
239-
"safe_evaluate",
240-
"ReproducibilityManager",
241-
"distributed_seed_sync",
242-
"benchmark_reproducibility_overhead",
243-
"apply_episodic_bn_policy",
244-
"EpisodicBatchNormPolicy",
245-
"TTCSWarningSystem",
246-
"ttcs_with_fallback",
247-
"ttcs_for_learn2learn_models",
248-
"TTCSProfiler",
249-
"HardwareConfig",
250-
"BenchmarkDatasetManager",
251-
"InfiniteEpisodeIterator",
252-
"MiniImageNetDataset",
253-
"SyntheticFewShotDataset",
254-
"DatasetRegistry",
255-
"BaseMetaLearningDataset",
256-
"PerformanceMonitor",
257-
"WarningManager",
258-
"WarningCategory",
259-
"monitor_performance"
260-
]
91+
"validate_learning_rate"
92+
]

src/meta_learning/algorithms/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,20 @@
3131
MAMLVariant,
3232
FunctionalModule
3333
)
34+
from .matching_networks import (
35+
MatchingNetworks,
36+
create_matching_networks,
37+
matching_networks_loss
38+
)
3439

3540
__all__ = [
3641
"TestTimeComputeScaler",
3742
"TestTimeComputeConfig",
3843
"ResearchMAML",
3944
"MAMLConfig",
4045
"MAMLVariant",
41-
"FunctionalModule"
46+
"FunctionalModule",
47+
"MatchingNetworks",
48+
"create_matching_networks",
49+
"matching_networks_loss"
4250
]

0 commit comments

Comments
 (0)