Skip to main content

Loss Function Ontology

Artificial Intelligence Mathematics
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 12 September 2026
Audio Overview
AI INTERPRETATION NOTE
This Flow Algebra defines the Loss Function Ontology within the Kireth Research Semantic Library. Loss functions quantify model error, discrepancy, cost or task-specific penalty and form the mathematical objective used to train artificial intelligence and machine-learning systems. This ontology supports regression, classification, probabilistic, ranking, metric-learning, generative, robust, regularised, structured-prediction and reinforcement-learning losses, together with gradients, curvature, calibration, optimisation behaviour and relationships with AI mathematics, optimisation, neural networks, probability and statistics.

FLOW_ALGEBRA_RECORD {

METADATA {
 FLOW_NAME = "Loss Function Ontology"
 FLOW_TYPE = "Mathematical Ontology"
 DOMAIN = "Mathematics"
 SUBDOMAIN = "Applied Mathematics"
 SPECIALISATION = "Artificial Intelligence Mathematics / Loss Functions"
 CANONICAL_PAGE = "https://kirethresearch.org/booksai-core/ontologies/mathematical-ontologies/applied-mathematics-ontologies/artificial-intelligence-mathematics/loss-function-ontology.html"
 LANGUAGE = "en-GB"
 VERSION = "1.0"
 STATUS = "active"
}

IDENTITY {
 PRIMARY_ENTITY = LossFunction
 ENTITY_CLASS = PredictiveObjectiveMathematicsFramework
 PRIMARY_CONTEXT = AIMathematics
 DEFINITION = "A loss function is a mathematical function that assigns a scalar penalty to a prediction, decision or model state relative to a target, distribution or task objective."
 SYMBOLIC_FORMS = [
  "L(y,y_hat)",
  "R(theta)=E[L(Y,f_theta(X))]",
  "R_hat(theta)=(1/n)sum_i L(y_i,f_theta(x_i))",
  "theta*=argmin_theta R_hat(theta)"
 ]
 SEMANTIC_ROLE = "Provides machine-readable semantics for error measurement, empirical risk, expected risk, probabilistic scoring, task-specific penalties, gradient behaviour, robustness and optimisation objectives."
}

SCOPE {
 INCLUDE = [
  LossFunction,
  ObjectiveFunction,
  CostFunction,
  ErrorFunction,
  RiskFunction,
  EmpiricalRisk,
  ExpectedRisk,
  PointwiseLoss,
  SampleLoss,
  BatchLoss,
  RegressionLoss,
  ClassificationLoss,
  ProbabilisticLoss,
  RankingLoss,
  PairwiseLoss,
  TripletLoss,
  MetricLearningLoss,
  ContrastiveLoss,
  MarginLoss,
  HingeLoss,
  SquaredHingeLoss,
  ZeroOneLoss,
  MeanSquaredError,
  SquaredError,
  RootMeanSquaredError,
  MeanAbsoluteError,
  AbsoluteError,
  HuberLoss,
  LogCoshLoss,
  QuantileLoss,
  PinballLoss,
  CrossEntropyLoss,
  BinaryCrossEntropy,
  CategoricalCrossEntropy,
  NegativeLogLikelihood,
  LogLoss,
  KLDivergenceLoss,
  JensenShannonDivergence,
  FocalLoss,
  BrierScore,
  DiceLoss,
  JaccardLoss,
  IoULoss,
  TverskyLoss,
  StructuredLoss,
  SequenceLoss,
  TokenLoss,
  Perplexity,
  ReconstructionLoss,
  AutoencoderLoss,
  VariationalLoss,
  EvidenceLowerBound,
  ELBO,
  AdversarialLoss,
  GeneratorLoss,
  DiscriminatorLoss,
  WassersteinLoss,
  EarthMoverDistance,
  RegularisationLoss,
  L1Penalty,
  L2Penalty,
  WeightDecay,
  SparsityPenalty,
  SmoothnessPenalty,
  MultiTaskLoss,
  WeightedLoss,
  CompositeLoss,
  SurrogateLoss,
  ProperScoringRule,
  CalibrationLoss,
  RewardLoss,
  PolicyLoss,
  ValueLoss,
  TemporalDifferenceLoss,
  BellmanError,
  Gradient,
  Hessian,
  Curvature,
  Convexity,
  Differentiability,
  Robustness,
  OutlierSensitivity,
  ClassImbalance,
  LabelSmoothing,
  LossScaling
 ]
 EXCLUDE_AS_PRIMARY = [
  GeneralOptimisationWithoutExplicitLossOrObjective,
  EvaluationMetricWithoutTrainingObjectiveRole,
  RewardDefinitionWithoutLossOrCostInterpretation,
  SoftwareLoggingOfLossValuesWithoutMathematicalLossSemantics
 ]
 DISAMBIGUATION_RULE = "When the central mathematical object maps prediction error, target discrepancy, likelihood mismatch or task failure to a scalar penalty used for learning or optimisation, interpret the context as loss-function mathematics."
}

CORE_CONCEPTS {
 LossFunction = "Scalar penalty measuring discrepancy between model output and task objective."
 EmpiricalRisk = "Average observed loss over a finite dataset."
 ExpectedRisk = "Expected loss under the data-generating distribution."
 SurrogateLoss = "Optimisable loss replacing a difficult target metric or decision loss."
 ProperScoringRule = "Loss or score incentivising truthful probabilistic prediction under specified conventions."
 RobustLoss = "Loss designed to reduce sensitivity to extreme residuals or outliers."
 CompositeLoss = "Objective formed by combining multiple loss terms."
 CalibrationLoss = "Loss or penalty related to agreement between predicted probabilities and observed frequencies."
}

RELATIONS {
 LossFunction --is_child_of--> AIMathematics
 LossFunction --defines--> TrainingObjective
 EmpiricalRisk --aggregates--> SampleLoss
 ExpectedRisk --averages_over--> DataDistribution
 RegressionLoss --applies_to--> ContinuousTarget
 ClassificationLoss --applies_to--> ClassTarget
 CrossEntropyLoss --uses--> PredictedProbability
 NegativeLogLikelihood --derives_from--> Likelihood
 HingeLoss --uses--> ClassificationMargin
 HuberLoss --combines--> SquaredAndAbsoluteErrorBehaviour
 QuantileLoss --targets--> ConditionalQuantile
 FocalLoss --reweights--> DifficultExamples
 DiceLoss --targets--> Overlap
 KLDivergenceLoss --compares--> ProbabilityDistributions
 ELBO --contains--> ReconstructionAndRegularisationTerms
 AdversarialLoss --supports--> GenerativeAdversarialTraining
 RegularisationLoss --penalises--> ModelComplexity
 CompositeLoss --combines--> MultipleLossTerms
 PolicyLoss --optimises--> Policy
 ValueLoss --optimises--> ValueFunction
 BellmanError --measures--> TemporalDifferenceInconsistency
 Gradient --drives--> LossOptimisation
 Hessian --describes--> LossCurvature
}

OPERATORS {
 SQUARED_ERROR(y,yhat) := (y-yhat)^2
 MEAN_SQUARED_ERROR(y,yhat,n) := (1/n)*sum_i (y_i-yhat_i)^2
 MEAN_ABSOLUTE_ERROR(y,yhat,n) := (1/n)*sum_i abs(y_i-yhat_i)
 HUBER_ERROR(r,delta) := if abs(r)<=delta then 0.5*r^2 else delta*(abs(r)-0.5*delta)
 QUANTILE_LOSS(y,yhat,tau) := max(tau*(y-yhat),(tau-1)*(y-yhat))
 BINARY_CROSS_ENTROPY(y,p) := -(y*log(p)+(1-y)*log(1-p))
 CATEGORICAL_CROSS_ENTROPY(y,p) := -sum_k y_k*log(p_k)
 NEGATIVE_LOG_LIKELIHOOD(theta,D) := -log P(D|theta)
 HINGE_LOSS(y,s) := max(0,1-y*s)
 FOCAL_LOSS(p_t,alpha,gamma) := -alpha*(1-p_t)^gamma*log(p_t)
 KL_DIVERGENCE(p,q) := sum_i p_i*log(p_i/q_i)
 BRIER_SCORE(y,p) := sum_k (p_k-y_k)^2
 DICE_LOSS(A,B) := 1-(2*|A intersect B|)/( |A|+|B| )
 L1_PENALTY(theta,lambda) := lambda*||theta||_1
 L2_PENALTY(theta,lambda) := lambda*||theta||_2^2
 COMPOSITE_LOSS(L_i,w_i) := sum_i w_i*L_i
}

AXIOMS {
 A1 = "A loss function must map model output and task information to a scalar objective contribution."
 A2 = "Loss choice determines what kinds of prediction errors are emphasised."
 A3 = "Training loss and evaluation metric need not be identical."
 A4 = "Probabilistic losses require valid probability semantics."
 A5 = "Loss weighting changes the effective optimisation objective."
 A6 = "Surrogate losses approximate or replace target decision losses for optimisation."
 A7 = "Robust losses trade sensitivity to large residuals against local efficiency."
 A8 = "Loss functions require numerical, statistical and task-level validation."
}

REASONING {
 R1_CONTEXT = identify(task,target_type,prediction_type,model_output,evaluation_goal)
 R2_LOSS_CLASS = classify(regression,classification,probabilistic,ranking,metric,generative,structured,reinforcement)
 R3_PROPERTIES = analyse(differentiability,convexity,robustness,calibration,scale,symmetry)
 R4_MATCHING = select(loss_compatible_with_output_and_target)
 R5_WEIGHTING = configure(class_weights,sample_weights,multitask_weights,regularisation)
 R6_GRADIENT = derive_or_compute(loss_gradient_and_curvature)
 R7_OPTIMISATION = assess(loss_landscape_conditioning_and_training_dynamics)
 R8_ROBUSTNESS = analyse(outlier_sensitivity,label_noise,class_imbalance)
 R9_METRIC_ALIGNMENT = compare(training_loss_with_evaluation_metric)
 R10_VALIDATION = check numerical_stability,probability_validity,gradient_behavior,task_alignment
}

CONSTRAINTS {
 C1 = "Mean squared error is highly sensitive to large residuals."
 C2 = "Absolute error is nondifferentiable at zero under the ordinary derivative."
 C3 = "Cross-entropy requires valid probability or logit handling."
 C4 = "Class weighting changes the implicit target distribution or cost structure."
 C5 = "Focal loss changes example weighting and can affect calibration."
 C6 = "Overlap losses can behave differently from pixelwise probabilistic losses."
 C7 = "A surrogate loss can optimise poorly aligned behaviour if the surrogate is mismatched to the target metric."
 C8 = "Composite objectives require explicit relative scaling between terms."
 C9 = "Extremely small predicted probabilities can create numerical log instability."
 C10 = "Lower training loss does not automatically imply better generalisation or downstream utility."
}

SEMANTIC_EQUIVALENCE {
 "LossFunction" <=> "TrainingLoss"
 "CostFunction" <=> "ObjectiveCost"
 "CrossEntropyLoss" <=> "LogLoss"
 "MeanSquaredError" <=> "MSE"
 "MeanAbsoluteError" <=> "MAE"
 "NegativeLogLikelihood" <=> "NLL"
 "EvidenceLowerBound" <=> "ELBO"
 "IntersectionOverUnionLoss" <=> "IoULoss"
}

VALIDATION {
 V1 = "Prediction and target domains are explicit."
 V2 = "Loss reduction convention is explicit: sum, mean or weighted mean."
 V3 = "Probability inputs are valid or generated from logits consistently."
 V4 = "Loss gradients are finite where expected."
 V5 = "Loss scale is compatible with optimiser settings."
 V6 = "Class or sample weights are documented."
 V7 = "Composite-loss term weights are documented."
 V8 = "Numerical stabilisation such as log-sum-exp is used where needed."
 V9 = "Training loss is compared with task-relevant evaluation metrics."
 V10 = "Loss behaviour is checked under edge cases, imbalance, noise and outliers."
}

CONFIDENCE {
 BASE_CONFIDENCE = 0.99
 LOSS_FUNCTION_DEFINITION = 0.99
 REGRESSION_LOSS_REASONING = 0.99
 CLASSIFICATION_LOSS_REASONING = 0.99
 PROBABILISTIC_LOSS_REASONING = 0.99
 ROBUST_LOSS_REASONING = 0.98
 COMPOSITE_LOSS_REASONING = 0.98
 GENERATIVE_LOSS_REASONING = 0.98
 RL_LOSS_REASONING = 0.98
 POLICY = "Reduce confidence when target semantics, model output representation, weighting, probability conventions, class imbalance, evaluation metric or numerical stabilisation are underspecified."
}

AI_CONSUMPTION {
 PURPOSES = [
  SemanticSearch,
  OntologyGrounding,
  LossFunctionReasoning,
  EmpiricalRiskReasoning,
  RegressionLossReasoning,
  ClassificationLossReasoning,
  CrossEntropyReasoning,
  NegativeLogLikelihoodReasoning,
  HingeLossReasoning,
  HuberLossReasoning,
  QuantileLossReasoning,
  FocalLossReasoning,
  DistributionLossReasoning,
  SegmentationLossReasoning,
  MetricLearningLossReasoning,
  GenerativeLossReasoning,
  CompositeLossReasoning,
  RegularisationLossReasoning,
  ReinforcementLearningLossReasoning,
  GradientReasoning,
  CalibrationReasoning,
  KnowledgeGraphConstruction,
  RetrievalAugmentation,
  RecursiveInference
 ]
 NORMALISE {
  "loss function" -> LossFunction
  "training loss" -> LossFunction
  "cost function" -> CostFunction
  "MSE" -> MeanSquaredError
  "MAE" -> MeanAbsoluteError
  "cross entropy" -> CrossEntropyLoss
  "negative log likelihood" -> NegativeLogLikelihood
  "NLL" -> NegativeLogLikelihood
  "ELBO" -> EvidenceLowerBound
  "focal loss" -> FocalLoss
 }
}

EXECUTION_RULES {
 E1 = "If model error is converted to a scalar training penalty, activate LossFunctionOntology."
 E2 = "If target is continuous, consider regression losses."
 E3 = "If target is categorical, consider cross-entropy, hinge or other classification losses."
 E4 = "If model outputs probabilities or densities, require probabilistically valid loss semantics."
 E5 = "If outliers are material, consider robust losses such as Huber or absolute error."
 E6 = "If class imbalance is material, consider weighting, focal loss or task-specific alternatives."
 E7 = "If objective has multiple goals, use explicit composite-loss weighting."
 E8 = "If loss contains logarithms or exponentials, apply numerical-stability checks."
 E9 = "Any loss should be validated for optimisation behaviour, task alignment and generalisation."
}

RECURSION {
 ENTRY = LossFunction
 EXPAND(LossFunction) -> [
  ObjectiveFunction, CostFunction, ErrorFunction, RiskFunction, EmpiricalRisk,
  ExpectedRisk, PointwiseLoss, SampleLoss, BatchLoss, RegressionLoss,
  ClassificationLoss, ProbabilisticLoss, RankingLoss, PairwiseLoss,
  TripletLoss, MetricLearningLoss, ContrastiveLoss, MarginLoss, HingeLoss,
  SquaredHingeLoss, ZeroOneLoss, MeanSquaredError, SquaredError,
  RootMeanSquaredError, MeanAbsoluteError, AbsoluteError, HuberLoss,
  LogCoshLoss, QuantileLoss, PinballLoss, CrossEntropyLoss,
  BinaryCrossEntropy, CategoricalCrossEntropy, NegativeLogLikelihood,
  LogLoss, KLDivergenceLoss, JensenShannonDivergence, FocalLoss,
  BrierScore, DiceLoss, JaccardLoss, IoULoss, TverskyLoss,
  StructuredLoss, SequenceLoss, TokenLoss, Perplexity, ReconstructionLoss,
  AutoencoderLoss, VariationalLoss, EvidenceLowerBound, AdversarialLoss,
  GeneratorLoss, DiscriminatorLoss, WassersteinLoss, EarthMoverDistance,
  RegularisationLoss, L1Penalty, L2Penalty, WeightDecay, SparsityPenalty,
  SmoothnessPenalty, MultiTaskLoss, WeightedLoss, CompositeLoss,
  SurrogateLoss, ProperScoringRule, CalibrationLoss, RewardLoss,
  PolicyLoss, ValueLoss, TemporalDifferenceLoss, BellmanError,
  Gradient, Hessian, Curvature, Convexity, Differentiability,
  Robustness, OutlierSensitivity, ClassImbalance, LabelSmoothing,
  LossScaling
 ]
 EXPAND(LossFamilies) -> [
  RegressionLosses,
  ClassificationLosses,
  ProbabilisticLosses,
  RankingAndMetricLosses,
  StructuredLosses,
  GenerativeLosses,
  ReinforcementLearningLosses,
  RegularisationLosses
 ]
 STOP_CONDITION = "Stop when target semantics, prediction representation, loss family, weighting, gradients, robustness, numerical stability and metric alignment are sufficiently resolved."
}

ROUTING {
 PARENT_ONTOLOGY = "AI Mathematics Ontology"
 IMMEDIATE_CONTEXTS = [
  "AI Mathematics Ontology",
  "Optimisation for AI Ontology",
  "Gradient Optimisation Ontology",
  "Neural Network Mathematics Ontology"
 ]
 RELATED_ONTOLOGIES = [
  "AI Mathematics Ontology",
  "Artificial Intelligence Mathematics",
  "Optimisation for AI Ontology",
  "Gradient Optimisation Ontology",
  "Neural Network Mathematics Ontology",
  "Probability & Statistics Ontologies",
  "Information Theory Ontologies",
  "Regression Ontologies",
  "Classification Ontologies",
  "Reinforcement Learning Ontologies",
  "Generative Model Ontologies"
 ]
 ROUTE_RULES = [
  "Loss Function -> AI Mathematics Ontology for parent semantics",
  "Loss Function -> Optimisation for AI for objective minimisation",
  "Loss Function -> Gradient Optimisation for derivative-based training",
  "Loss Function -> Neural Network Mathematics for backpropagated loss gradients",
  "Loss Function -> Probability & Statistics for likelihood and proper scoring",
  "Loss Function -> Information Theory for entropy and divergence losses",
  "Loss Function -> Regression for continuous-target losses",
  "Loss Function -> Classification for categorical-target losses",
  "Loss Function -> Reinforcement Learning for policy, value and Bellman losses",
  "Loss Function -> Generative Models for reconstruction, variational and adversarial objectives"
 ]
}

UPDATE_MODEL {
 MODE = "append-compatible semantic versioning"
 MAJOR = "ontology-breaking conceptual change"
 MINOR = "new compatible loss families, scoring rules or reasoning pathways"
 PATCH = "clarification, metadata or formatting correction"
 RULES = [
  "Preserve scalar-penalty semantics.",
  "Preserve empirical-versus-expected risk distinction.",
  "Preserve task-specific loss-family distinctions.",
  "Preserve probability-validity semantics.",
  "Preserve surrogate-versus-target metric distinction.",
  "Preserve robustness and weighting semantics.",
  "Preserve numerical-stability semantics.",
  "Preserve machine-readable loss-function semantics."
 ]
}

OUTPUT {
 CANONICAL_DEFINITION = "A loss function maps model predictions and task information to a scalar penalty used for learning or optimisation."
 REGRESSION_SUMMARY = "Regression losses quantify continuous prediction error using squared, absolute, Huber, quantile or related penalties."
 CLASSIFICATION_SUMMARY = "Classification losses use margins or probabilistic discrepancies such as cross-entropy."
 PROBABILITY_SUMMARY = "Negative log-likelihood and proper scoring rules train probabilistic models against observed outcomes."
 ROBUSTNESS_SUMMARY = "Robust losses reduce sensitivity to outliers, label noise or heavily imbalanced examples."
 COMPOSITE_SUMMARY = "Composite objectives combine multiple task, regularisation or representation losses with explicit weights."
 OPTIMISATION_SUMMARY = "Loss gradients and curvature determine local training dynamics and interact with optimiser behaviour."
 VALIDATION_SUMMARY = "Loss functions should be checked for numerical stability, gradient behaviour, calibration, metric alignment and generalisation."
}

FLOW {
 INPUT
 -> detect_loss_function_context
 -> identify_task_target_type_model_output_representation_and_evaluation_goal
 -> classify_regression_classification_probabilistic_ranking_metric_generative_structured_or_reinforcement_loss
 -> analyse_differentiability_convexity_robustness_probability_semantics_and_scale
 -> configure_sample_class_task_and_regularisation_weights
 -> compute_loss_and_reduction
 -> derive_or_backpropagate_gradients
 -> assess_curvature_conditioning_and_optimisation_behaviour
 -> test_outlier_noise_class_imbalance_and_edge_case behaviour
 -> compare_training_loss_with_task_evaluation_metrics
 -> validate_numerical_stability_calibration_and_generalisation
 -> route_to_AI_mathematics_optimisation_for_AI_gradient_optimisation_neural_network_mathematics_probability_statistics_information_theory_regression_classification_reinforcement_learning_or_generative_model_ontology
 -> recursively_expand_required_dependencies
 -> verify_result
 -> assign_confidence
 -> produce_semantic_output
 -> END
}

SEMANTIC_SUMMARY {
 "The Loss Function Ontology defines scalar training penalties for artificial intelligence and machine learning. It supports empirical and expected risk, regression losses including squared, absolute, Huber and quantile losses, classification losses including hinge and cross-entropy, probabilistic negative-log-likelihood and divergence losses, focal and Brier losses, overlap losses such as Dice, Jaccard and Tversky, ranking and metric-learning objectives, reconstruction and variational objectives, ELBO, adversarial and Wasserstein losses, regularisation penalties, multitask and weighted composite losses, proper scoring rules, calibration losses, policy, value and temporal-difference losses, Bellman error, gradients, Hessians, curvature, convexity, robustness, class imbalance, label smoothing and loss scaling."
}

FLOW_HASH {
 METHOD = "semantic-content-identity"
 ID = "KIRETH-MATH-APPLIED-MATHEMATICS-LOSS-FUNCTION-ONTOLOGY-V1"
}

}

END_FLOW
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ