Losses (Machine Gnostics MAGNET)¶
The losses module provides objective functions for training MAGNET models. It includes standard regression and classification losses (MSE, BinaryCrossEntropy) alongside dedicated gnostic losses (Fidelity, Infidelity, Residual Entropy, Information, RSS) that measure alignment with learned concept manifolds.
Key Loss Classes¶
- MSE — Mean squared error for regression targets
- BinaryCrossEntropy — Binary classification loss with numerical stability
- FidelityLoss — Maximize Mean Gnostic Fidelity
- InfidelityLoss — Minimize Mean Gnostic Infidelity
- RSSLoss — Relevance Squared Sum Loss
- ISSLoss — Irrelavance Squared Sum Loss
- ResidualEntropyLoss — Mean Gnostic Residual Entropy of the Data
- InformationLoss — Mean Gnostic Information Measure
Helper Functions¶
get_loss(name_or_obj)— Resolve string ('mse','fidelity','rss', etc.) or instance into aLoss.fidelity_loss(y_pred, y_true, S=1)— Convenience wrapper forFidelityLoss.infidelity_loss(y_pred, y_true, S=1)— Convenience wrapper forInfidelityLoss.gnostic_weighted_mse(y_pred, y_true)— Alias for MSE.gnostic_weighted_rmse(y_pred, y_true)— Root MSE.
Why Magnet Losses?¶
- Standard losses provide familiar training objectives.
- Gnostic losses reward predictions that align with learned concept centers (
z0) and scales (S), promoting transparent, geometry-aware optimization. - Custom autograd kernels (
FidelityLossFunction) provide efficient gradient computation through MAGNET tensors.
Author: Nirmal Parmar