82 lines
2.4 KiB
Rust
82 lines
2.4 KiB
Rust
//! Comprehensive RTX Losses - Complete Loss Function Library
|
|
//!
|
|
//! This provides working implementations of critical loss functions for:
|
|
//! - **Metric Learning**: TripletLoss with distance metrics and mining strategies
|
|
//! - **Contrastive Learning**: InfoNCE, SwAV, SimCLR for self-supervised learning
|
|
//! - **Robust Regression**: HuberLoss, QuantileLoss, LogCoshLoss for outlier-resistant training
|
|
//!
|
|
//! All implementations use a minimal tensor backend to avoid ecosystem compilation issues
|
|
//! while providing full functionality and comprehensive test coverage.
|
|
|
|
pub mod bce_with_logits_loss;
|
|
pub mod center_loss;
|
|
pub mod combined_loss;
|
|
pub mod error_minimal;
|
|
pub mod hinge_loss;
|
|
pub mod huber_loss;
|
|
pub mod info_nce_minimal;
|
|
pub mod iou_loss;
|
|
pub mod kl_divergence_loss;
|
|
pub mod logcosh_loss;
|
|
pub mod mae_loss;
|
|
pub mod minimal_tensor;
|
|
pub mod quantile_loss;
|
|
pub mod reduction_minimal;
|
|
pub mod simclr_minimal;
|
|
pub mod swav_minimal;
|
|
pub mod triplet_loss;
|
|
pub mod wasserstein_loss;
|
|
|
|
#[cfg(test)]
|
|
mod integration_test;
|
|
#[cfg(test)]
|
|
mod triplet_test_standalone;
|
|
|
|
// Re-export main types
|
|
pub use error_minimal::{LossError, Result};
|
|
pub use minimal_tensor::{MinimalDevice, MinimalTensor};
|
|
pub use reduction_minimal::Reduction;
|
|
|
|
// Self-supervised and contrastive learning losses
|
|
pub use info_nce_minimal::InfoNCEMinimal;
|
|
pub use simclr_minimal::SimCLRMinimal;
|
|
pub use swav_minimal::SwAVMinimal;
|
|
|
|
// Metric learning losses
|
|
pub use triplet_loss::{DistanceMetric, TripletLoss};
|
|
|
|
// Robust regression losses
|
|
pub use huber_loss::HuberLoss;
|
|
pub use logcosh_loss::LogCoshLoss;
|
|
pub use quantile_loss::QuantileLoss;
|
|
|
|
// SVM-based classification losses
|
|
pub use hinge_loss::{HingeLoss, HingeLossVariant};
|
|
|
|
// Wasserstein distance and optimal transport losses
|
|
pub use wasserstein_loss::{GroundMetric, WassersteinDistance, WassersteinLoss};
|
|
|
|
// Face recognition and metric learning losses
|
|
pub use center_loss::CenterLoss;
|
|
|
|
// Basic regression losses
|
|
pub use mae_loss::MAELoss;
|
|
|
|
// Binary classification losses
|
|
pub use bce_with_logits_loss::BCEWithLogitsLoss;
|
|
|
|
// Distribution distance losses
|
|
pub use kl_divergence_loss::KLDivLoss;
|
|
|
|
// Computer vision losses
|
|
pub use iou_loss::{IoULoss, IoUVariant};
|
|
|
|
// Loss combination utilities
|
|
pub use combined_loss::{CombinedLoss, CombinedLossBuilder, LossComponent};
|
|
|
|
// Simplified Loss trait for minimal implementation
|
|
pub trait MinimalLoss {
|
|
/// Reduction mode for this loss
|
|
fn reduction(&self) -> Reduction;
|
|
}
|