Expand description
Training scaffolds: loss wiring, schedules, callbacks.
This crate provides comprehensive training infrastructure for Tensorlogic models:
- Loss functions (standard and logical constraint-based)
- Optimizer wrappers around SciRS2
- Training loops with callbacks
- Batch management
- Validation and metrics
- Regularization techniques
- Data augmentation
- Logging and monitoring
- Curriculum learning strategies
- Transfer learning utilities
- Hyperparameter optimization (grid search, random search)
- Cross-validation utilities
- Model ensembling
Structs§
- Accuracy
- Accuracy metric for classification.
- AdaBelief
Optimizer - AdaBelief optimizer (NeurIPS 2020).
- AdaMax
Optimizer - AdaMax optimizer (variant of Adam with infinity norm).
- Adagrad
Optimizer - Adagrad optimizer (Adaptive Gradient).
- Adam
Optimizer - Adam optimizer.
- AdamW
Optimizer - AdamW optimizer (Adam with decoupled weight decay).
- Averaging
Ensemble - Averaging ensemble for regression.
- BCEWith
Logits Loss - Binary cross-entropy with logits loss (numerically stable).
- Bagging
Helper - Bagging (Bootstrap Aggregating) utilities.
- Balanced
Accuracy - Balanced accuracy metric. Average of recall per class, useful for imbalanced datasets.
- Batch
Callback - Callback that logs batch progress.
- Batch
Config - Configuration for batch processing.
- Batch
Iterator - Iterator over batches of data.
- Callback
List - List of callbacks to execute in order.
- Checkpoint
Callback - Callback for model checkpointing.
- Cohens
Kappa - Cohen’s Kappa statistic. Measures inter-rater agreement, accounting for chance agreement. Ranges from -1 to +1, where 1 is perfect agreement, 0 is random chance.
- Competence
Curriculum - Competence-based curriculum: adapts to model’s current competence level.
- Composite
Augmenter - Composite augmenter that applies multiple augmentations sequentially.
- Composite
Regularization - Composite regularization that combines multiple regularizers.
- Confusion
Matrix - Confusion matrix for multi-class classification.
- Console
Logger - Console logger that outputs to stdout.
- Constraint
Violation Loss - Constraint violation loss - penalizes constraint violations.
- Contrastive
Loss - Contrastive loss for metric learning. Used to learn embeddings where similar pairs are close and dissimilar pairs are far apart.
- Cosine
Annealing LrScheduler - Cosine annealing learning rate scheduler. Anneals learning rate using a cosine schedule.
- Cross
Entropy Loss - Cross-entropy loss for classification.
- Cross
Validation Results - Cross-validation result aggregator.
- Curriculum
Manager - Manager for curriculum learning that tracks training progress.
- Cyclic
LrScheduler - Cyclic learning rate scheduler.
- Data
Shuffler - Data shuffler for randomizing training data.
- Dice
Loss - Dice loss for segmentation tasks.
- Discriminative
Fine Tuning - Discriminative fine-tuning: use different learning rates for different layers.
- Early
Stopping Callback - Callback for early stopping based on validation loss.
- Elastic
NetRegularization - Elastic Net regularization (combination of L1 and L2).
- Epoch
Callback - Callback that logs training progress.
- Exponential
Curriculum - Exponential curriculum: exponentially increase sample percentage.
- Exponential
LrScheduler - Exponential learning rate scheduler. Decreases learning rate by a factor of gamma every epoch.
- F1Score
- F1 score metric for classification.
- Feature
Extractor Mode - Feature extraction mode: freeze entire feature extractor.
- File
Logger - File logger that writes logs to a file.
- Focal
Loss - Focal loss for addressing class imbalance. Reference: Lin et al., “Focal Loss for Dense Object Detection”
- Gradient
Accumulation Callback - Gradient Accumulation callback.
- Gradient
Monitor - Gradient flow monitor for tracking gradient statistics during training.
- Gradient
Summary - Summary of gradient statistics.
- Grid
Search - Grid search strategy for hyperparameter optimization.
- Hinge
Loss - Hinge loss for maximum-margin classification (SVM-style).
- Histogram
Callback - Callback for tracking weight histograms during training.
- Histogram
Stats - Weight histogram statistics for debugging and monitoring.
- Huber
Loss - Huber loss for robust regression.
- Hyperparam
Result - Result of a hyperparameter evaluation.
- KFold
- K-fold cross-validation.
- KLDivergence
Loss - Kullback-Leibler Divergence loss. Measures how one probability distribution diverges from a reference distribution.
- L1Regularization
- L1 regularization (Lasso).
- L2Regularization
- L2 regularization (Ridge / Weight Decay).
- Lamb
Optimizer - LAMB optimizer (Layer-wise Adaptive Moments optimizer for Batch training). Designed for large batch training, uses layer-wise adaptation.
- Lars
Optimizer - LARS optimizer (Layer-wise Adaptive Rate Scaling).
- Layer
Freezing Config - Layer freezing configuration for transfer learning.
- Learning
Rate Finder - Learning rate finder callback using the LR range test.
- Leave
OneOut - Leave-one-out cross-validation.
- Linear
Curriculum - Linear curriculum: gradually increase the percentage of samples used.
- Linear
Model - A simple linear model for testing and demonstration.
- Logical
Loss - Logical loss combining multiple objectives.
- Lookahead
Optimizer - Lookahead optimizer (wrapper that uses slow and fast weights).
- Loss
Config - Configuration for loss functions.
- Matthews
Correlation Coefficient - Matthews Correlation Coefficient (MCC) metric. Ranges from -1 to +1, where +1 is perfect prediction, 0 is random, -1 is total disagreement. Particularly useful for imbalanced datasets.
- Metric
Tracker - Metric tracker for managing multiple metrics.
- Metrics
Logger - Metrics logger that aggregates and logs training metrics.
- Mixup
Augmenter - Mixup augmentation.
- ModelEMA
Callback - Model EMA (Exponential Moving Average) callback.
- MseLoss
- Mean squared error loss for regression.
- Multi
Step LrScheduler - Multi-step learning rate scheduler.
- NAdam
Optimizer - NAdam optimizer (Nesterov-accelerated Adam).
- NoAugmentation
- No augmentation (identity transformation).
- Noam
Scheduler - Noam scheduler (Transformer learning rate schedule).
- Noise
Augmenter - Gaussian noise augmentation.
- OneCycle
LrScheduler - One-cycle learning rate scheduler. Increases LR from initial to max, then decreases to min.
- Optimizer
Config - Configuration for optimizers.
- PerClass
Metrics - Per-class metrics report.
- Polynomial
Decay LrScheduler - Polynomial decay learning rate scheduler.
- Precision
- Precision metric for classification.
- Profiling
Callback - Callback for profiling training performance.
- Profiling
Stats - Performance profiling statistics.
- Progressive
Unfreezing - Progressive unfreezing strategy for transfer learning.
- RAdam
Optimizer - RAdam optimizer (Rectified Adam) with variance warmup (ICLR 2020).
- RMSprop
Optimizer - RMSprop optimizer (Root Mean Square Propagation).
- Random
Search - Random search strategy for hyperparameter optimization.
- Recall
- Recall metric for classification.
- ReduceLR
OnPlateau Scheduler - Reduce learning rate on plateau (metric-based adaptive scheduler).
- Reduce
LrOn Plateau Callback - Callback for learning rate reduction on plateau.
- RocCurve
- ROC curve and AUC computation utilities.
- Rotation
Augmenter - Rotation augmentation (placeholder for future implementation).
- Rule
Satisfaction Loss - Rule satisfaction loss - measures how well rules are satisfied.
- SWACallback
- SWA (Stochastic Weight Averaging) callback.
- SamOptimizer
- SAM optimizer (Sharpness Aware Minimization).
- Scale
Augmenter - Scale augmentation.
- Self
Paced Curriculum - Self-paced learning: model determines its own learning pace.
- SgdOptimizer
- SGD optimizer with momentum.
- Stacking
Ensemble - Stacking ensemble with a meta-learner.
- Step
LrScheduler - Step-based learning rate scheduler.
Decreases learning rate by a factor every
step_sizeepochs. - StratifiedK
Fold - Stratified K-fold cross-validation.
- Task
Curriculum - Task-level curriculum for multi-task learning.
- Tensor
Board Logger - TensorBoard logger (placeholder for future implementation).
- Time
Series Split - Time series split for temporal data.
- TopK
Accuracy - Top-K accuracy metric. Measures whether the correct class is in the top K predictions.
- Trainer
- Main trainer for model training.
- Trainer
Config - Configuration for training.
- Training
Checkpoint - Comprehensive checkpoint data structure.
- Training
History - Training history containing losses and metrics.
- Training
State - Training state passed to callbacks.
- Transfer
Learning Manager - Transfer learning strategy manager.
- Triplet
Loss - Triplet loss for metric learning. Learns embeddings where anchor-positive distance < anchor-negative distance + margin.
- Tversky
Loss - Tversky loss (generalization of Dice loss). Useful for handling class imbalance in segmentation.
- Validation
Callback - Callback for validation during training.
- Voting
Ensemble - Voting ensemble configuration.
- Warmup
Cosine LrScheduler - Warmup with cosine annealing scheduler.
Enums§
- Cyclic
LrMode - Cyclic learning rate mode.
- Grad
Clip Mode - Gradient clipping mode.
- Hyperparam
Space - Hyperparameter space definition.
- Hyperparam
Value - Hyperparameter value type.
- Plateau
Mode - Mode for ReduceLROnPlateau scheduler.
- Train
Error - Errors that can occur during training.
- Voting
Mode - Voting ensemble for classification.
Traits§
- Autodiff
Model - Trait for models that support automatic differentiation via scirs2-autograd.
- Callback
- Trait for training callbacks.
- Cross
Validation Split - Trait for cross-validation splitting strategies.
- Curriculum
Strategy - Trait for curriculum learning strategies.
- Data
Augmenter - Trait for data augmentation strategies.
- Dynamic
Model - Trait for models with dynamic computation graphs.
- Ensemble
- Trait for ensemble methods.
- Logging
Backend - Trait for logging backends.
- Loss
- Trait for loss functions.
- LrScheduler
- Trait for learning rate schedulers.
- Metric
- Trait for metrics.
- Model
- Trait for trainable models.
- Optimizer
- Trait for optimizers.
- Regularizer
- Trait for regularization strategies.
Functions§
- extract_
batch - Extract batches from data arrays.
Type Aliases§
- Hyperparam
Config - Hyperparameter configuration (a single point in parameter space).
- Train
Result - Result type for training operations.