Objective function
An objective function assigns values to candidate solutions, predictions, or parameter settings according to a criterion to be minimized or maximized.
Advanced Algorithms and Data Structures
A loss function is a function that quantifies the discrepancy between model predictions and observed target values.
- How it is used
- Scores candidate solutions so optimization can seek low-cost graph drawings, routes, or fitted models.
- How deep it goes
- Develops definitions, cost landscapes, squared-error regression, and derivative-based graph updates; defers a fuller treatment of supervised learning.
- Examples
- Uses crossing counts, squared-error regression, force-directed drawing, and traveling-salesperson tour costs.
- What you can do after
- Evaluate/understand which objective suits a problem and whether its shape and evaluation cost favor gradient descent or simulated annealing.
Read how Advanced Algorithms and Data Structures explains objective function →
Grokking Machine Learning
Training error is a measure of a model's prediction error on the data used to train it.
- How it is used
- Measures model mistakes during training and supplies a quantity to reduce while fitting regression, classifiers, and neural networks.
- How deep it goes
- Defines errors geometrically, compares classifier objectives, and sketches gradient-based reduction; neural-network backpropagation is given as pseudocode.
- Examples
- Compares point-to-line distances, polynomial models’ training and testing errors, and four models in a selection exercise.
- What you can do after
- Evaluate/understand it by comparing candidate models’ errors and checking held-out error before choosing a model.
Read how Grokking Machine Learning explains objective function →
Math and Architectures of Deep Learning
A function assigning a scalar penalty to model parameters or predictions.
- How it is used
- Defines the quantitative target minimized while training supervised models and neural networks.
- How deep it goes
- Develops per-instance and total loss, squared-error and cross-entropy forms, loss-surface geometry, and gradient-based minimization.
- Examples
- Uses linear and parabolic losses, four-class image predictions, normalized image reconstruction, and Fast R-CNN RoI losses.
- What you can do after
- Evaluate/understand how a loss quantifies mismatch and guides parameter updates toward lower training error.
Read how Math and Architectures of Deep Learning explains objective function →
Optimization Algorithms: AI techniques for design, planning, and control problems
A loss is a scalar measure of discrepancy between a model prediction and a target that an optimization procedure seeks to reduce.
- How it is used
- Scores candidate decisions for constrained search and, as loss, scores neural-network predictions against expected outputs.
- How deep it goes
- Defines optimization directions and works through a derivative-based profit maximum, then shows a Python classification-loss calculation without requiring differentiability for black-box search.
- Examples
- Uses conference ticket pricing, electric-vehicle design, cargo-bike loading, and neural-network training to illustrate different objectives.
- What you can do after
- Build it from scratch for ticket-price profit or classification loss, then use its value to compare candidate solutions.
Bayesian Optimization in Action
An objective function is a function whose input is selected to maximize or minimize its output.
- How it is used
- Frames expensive black-box optimization as repeatedly querying inputs to find a maximum with few evaluations.
- How deep it goes
- Defines black-box objectives and develops one-dimensional, constrained, and four-parameter optimization examples with GP-based implementations.
- Examples
- Uses a hidden one-dimensional function, simulated airplane utility, and a constrained Forrester-function scenario with a cost function.
- What you can do after
- Apply it via BoTorch to model objective and cost observations and optimize for better feasible solutions.
Read how Bayesian Optimization in Action explains objective function →
Grokking AI Algorithms, Second Edition
Training loss is the loss computed on the examples used to fit a model.
- How it is used
- Uses loss on training examples to measure prediction error and guide neural-network weight updates.
- How deep it goes
- Works through numerical errors, mean squared error, cross-entropy intuition, and backpropagation steps; leaves some gradient-update code as a placeholder.
- Examples
- Compares class predictions, next-token probabilities, and predicted versus actual image noise.
- What you can do after
- Evaluate/understand training progress by interpreting loss trends and checking validation loss for overfitting.
Read how Grokking AI Algorithms, Second Edition explains objective function →
Deep Learning with PyTorch, Second Edition
Loss computed on training data during fitting.
- How it is used
- Guides parameter updates by scoring model outputs against desired outputs during training.
- How deep it goes
- Defines loss, compares error formulas, implements mean squared loss, and uses it in a backward-pass training loop.
- Examples
- Uses thermometer calibration, bird-versus-airplane classification, and image-noise prediction to show how targets determine losses.
- What you can do after
- Build it from scratch as mean squared loss, then apply it in a PyTorch training loop and diagnose loss trends.
Read how Deep Learning with PyTorch, Second Edition explains objective function →
Natural Language Processing in Action, Second Edition
Loss is a numerical measure of discrepancy between a model's prediction and a desired target, with lower values generally indicating better agreement.
- How it is used
- Guides weight updates during training and can score candidate chatbot responses for selection.
- How deep it goes
- Defines loss through an analogy, compares task-specific losses, and works through PyTorch optimization; defers detailed mean squared error treatment.
- Examples
- Uses birth-certificate name classification, frequency-weighted binary cross-entropy, and printed training and test measurements.
- What you can do after
- Apply it via PyTorch to select a classification loss, update weights, and monitor training and test results.
Read how Natural Language Processing in Action, Second Edition explains objective function →
Deep Learning with R, Third Edition
A loss function is a function that assigns a numerical measure of discrepancy between a model's prediction and the true target.
- How it is used
- Supplies the feedback signal that steers neural-network weight updates toward predictions that better match targets.
- How deep it goes
- Develops the definition through Keras configuration, task-selection rules, and a coded custom detection loss without a formal derivation.
- Examples
- Uses MNIST digit classification and a YOLO bounding-box loss as concrete cases.
- What you can do after
- Apply it via Keras `compile()` to choose a task-matched loss, or build a custom loss for bounding boxes.
Read how Deep Learning with R, Third Edition explains objective function →
Machine Learning System Design
A loss is a numerical value representing the discrepancy between a machine learning model's output and a target value for an instance or collection of instances.
- How it is used
- Directs model training toward particular errors while metrics check whether that behavior serves the system’s goal.
- How deep it goes
- Explains selection criteria and practical tradeoffs, including differentiability and alignment with goals, without deriving optimization algorithms.
- Examples
- Uses imbalanced classification, retail quantile forecasts, spam classification, and training-versus-validation loss curves.
- What you can do after
- Diagnose/debug with it by checking anomalous loss values and diverging training and validation curves, while testing alignment with operational metrics.
Read how Machine Learning System Design explains objective function →
Deep Learning with Python, Third Edition
A function that compares predictions with targets and returns a scalar indicating how wrong the model is for a given task.
- How it is used
- Turns prediction error into the feedback quantity an optimizer minimizes during neural-network training.
- How deep it goes
- Defines the training role, works through Keras configuration, and develops a custom object-detection loss without a dense mathematical derivation.
- Examples
- Uses handwritten-digit classification, integer-versus-categorical labels, and separate YOLO box and class losses.
- What you can do after
- Apply it via Keras `compile()` by selecting a task-appropriate loss or assigning losses to model outputs.
Read how Deep Learning with Python, Third Edition explains objective function →
Sutskever's List
Training loss is the value of an objective function measuring a model's error on examples used for parameter training.
- How it is used
- Guides parameter updates during neural-network training and helps forecast gains from additional model size, data, and compute.
- How deep it goes
- Defines loss through prediction error and explains gradient-based updates, then examines scaling behavior without deriving an objective mathematically.
- Examples
- Contrasts AlexNet’s mini-batch optimization with a random-label experiment that achieves high training accuracy but near-chance test accuracy.
- What you can do after
- Evaluate/understand low training loss as an optimization result, not by itself evidence of generalization or benchmark capability.
Data Without Labels
A loss function quantifies the discrepancy between predicted and actual values for evaluating a model.
- How it is used
- Provides a quantity to minimize when assessing predictions, training neural networks, or fitting lower-dimensional representations.
- How deep it goes
- Defines loss through prediction discrepancy, then works through network weight gradients; leaves the exact stress formula outside the supplied excerpt.
- Examples
- Uses product-demand forecasts, face-identification outputs, stress goodness-of-fit values, and fuzzy-clustering convergence.
- What you can do after
- Evaluate/understand it by reading a loss score as an optimization target and tracing how weight updates seek to reduce it.
Classic Computer Science Problems in Swift: Essential techniques for practicing programmers
An error function is a mathematical function that assigns a numerical measure to the discrepancy between predicted and expected outputs.
- How it is used
- Guides A* maze search by ranking frontier states according to path cost plus estimated remaining cost.
- How deep it goes
- Defines g(n), h(n), and f(n), then shows their use in Swift node comparison without developing a prediction-error objective.
- Examples
- Uses a grid maze, step counts, and Euclidean and Manhattan distance heuristics.
- What you can do after
- Apply it via A* search to prioritize maze locations using accumulated cost and a distance heuristic.
Machine Learning Algorithms in Depth
Training loss is the value of a model's loss function evaluated on examples in its training dataset.
- How it is used
- Uses an objective to guide training or split selection, with training loss measuring prediction error on training examples.
- How deep it goes
- Derives average misclassification and mean squared error and explains CART split costs; defers cross-entropy to later treatment.
- Examples
- Works through misclassification and squared error, then uses candidate feature thresholds and an Iris-based CART implementation.
- What you can do after
- Build it from scratch to score candidate CART splits and select a feature threshold using an impurity cost.
Read how Machine Learning Algorithms in Depth explains objective function →
Statistics Every Programmer Needs
An objective function is a mathematical expression that assigns a value to each feasible decision and is maximized or minimized in an optimization problem.
- How it is used
- Frames project prioritization as maximizing feature priority while respecting budgets and strategic balance constraints.
- How deep it goes
- Explains linear formulation, binary variables, score ratios, solver negation, constraints, and result evaluation without proving optimization algorithms.
- Examples
- Uses feature value-to-effort ratios, project budgets, epic selection bounds, Python coefficients, and scipy.optimize.linprog.
- What you can do after
- Build it from scratch by defining objective coefficients, encoding constraints, solving with linprog(), and evaluating selected alternatives.
Read how Statistics Every Programmer Needs explains objective function →
Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI
A loss function quantifies the discrepancy between model predictions and expected target values for optimization.
- How it is used
- Defines the optimization target that gradient boosting uses to improve predictions for regression, classification, count, survival, or ranking tasks.
- How deep it goes
- Explains objective selection and gradient-based corrections, but stops short of deriving the available loss functions mathematically.
- Examples
- Uses logistic classification, insurance claim distributions, event counts, and an Airbnb NYC gradient boosting implementation with measured accuracy.
- What you can do after
- Configure XGBoost objectives for different prediction tasks and distinguish training losses from evaluation metrics.
Designing Deep Learning Systems: A guide for software engineers
A function that maps hyperparameter settings and their resulting training outcomes to a scalar value to be minimized or maximized.
- How it is used
- Guides HPO libraries in scoring training trials and choosing subsequent hyperparameter suggestions.
- How deep it goes
- Explains inputs, training, evaluation, returned scores, and metric reporting, but defers detailed optimization algorithms.
- Examples
- Uses Hyperopt classifier selection, Optuna regressors, and Ray Tune convolutional-network accuracy reporting.
- What you can do after
- Build it from scratch: wrap training and evaluation in a callable accepted by Hyperopt, Optuna, or Ray Tune.
Learn Generative AI with PyTorch
The objective value minimized during training, here composed of reconstruction loss and KL divergence for the VAE.
- How it is used
- Uses a combined training target to balance image reconstruction with regularization of the VAE latent space.
- How deep it goes
- Explains the objective’s two terms and its backpropagation role, but does not derive their equations.
- Examples
- Uses reconstructed human faces, 196,608-pixel inputs, 100-value latent vectors, and randomly sampled encodings for novel images.
- What you can do after
- Apply it via a VAE training loop that computes combined loss and updates encoder and decoder parameters.
Read how Learn Generative AI with PyTorch explains objective function →
Build a Text-to-Image Generator (from Scratch)
A loss function is a function that quantifies the discrepancy between a model's predictions and the desired outputs.
- How it is used
- Guides model training by measuring prediction error and specifying the discrepancy to minimize.
- How deep it goes
- Explains task-specific losses and multi-term balancing, but does not derive their mathematical formulas or optimization algorithms.
- Examples
- Uses CIFAR-10 classification, VAE image reconstruction, and DALL-E mini image-token prediction as concrete objective-function examples.
- What you can do after
- Apply it via a selected loss, optimizer, batches, and training loop for classification or generative modeling.
Read how Build a Text-to-Image Generator (from Scratch) explains objective function →
Inside AI
An objective function is a function that assigns a value representing the performance or desirability of a candidate solution.
- How it is used
- Scores candidate solutions in genetic algorithms, assigning fitness values that guide selection.
- How deep it goes
- Defines it as a solution evaluator that assigns fitness scores, without specifying a formula for the evaluator.
- What you can do after
- Apply a chosen objective function to score candidate solutions in a genetic algorithm.
Introduction to Generative AI, Second Edition
A loss function is a mathematical function that quantifies prediction error or undesired behavior for optimization during model training.
- How it is used
- Frames the numerical goal that guides model training across supervised, unsupervised, and reinforcement learning.
- How deep it goes
- Defines objectives and training intuition but defers the precise mathematics of updating neural-network parameters.
- Examples
- Uses minimizing errors, reducing prediction differences, maximizing rewards, and balancing mixture-of-experts training as examples.
- What you can do after
- Evaluate/understand how learning settings define goals and how those goals guide parameter updates and expert balancing.
Read how Introduction to Generative AI, Second Edition explains objective function →
Generative AI in Action
Training loss is a metric measuring the error between a model’s predictions and actual outcomes on training examples.
- How it is used
- Monitors fine-tuning progress and guides judgment about whether model predictions are improving.
- How deep it goes
- Defines training and validation loss, explains step and epoch measurements, and stops short of mathematical derivation.
- Examples
- Uses batch-level loss curves from Azure OpenAI fine-tuning and a GPT-3.5 Turbo training-loss figure.
- What you can do after
- Evaluate fine-tuning progress by comparing training and validation loss across steps and epochs.
Read how Generative AI in Action explains objective function →
LLMs in Production
A loss function is an objective that quantifies discrepancies between a model's predictions and target outputs for optimization during training.
- How it is used
- Guides weight adjustment during batched LLM training by quantifying the calculated loss after predictions.
- How deep it goes
- Explains loss within the training loop and links it to epochs, weight updates, and overfitting without deriving its formula.
- Examples
- Uses a from-scratch language-model pipeline and a GPT-style PyTorch listing as concrete training contexts.
- What you can do after
- Apply it via a training loop that batches data, obtains predictions and loss, and performs backpropagation.
Causal AI
A loss function is an objective function that quantifies the cost or error associated with model parameters or predictions.
- How it is used
- Frames parameter estimation and decision selection as optimization over error, cost, likelihood, or desirability.
- How deep it goes
- Defines loss, connects it to likelihood and regularization, and contrasts analytical solutions with numerical optimization.
- Examples
- Uses L2 parameter penalties, investment payoffs, and a utility-node diagram to make objective design concrete.
- What you can do after
- Apply likelihood-based, regularized, or utility-based objectives when fitting models or comparing uncertain decisions.
Reinforcement Learning from Human Feedback
A loss function is a scalar objective that quantifies prediction or optimization error during model training.
- How it is used
- Guides parameter updates by converting prediction, reward, or preference quality into an optimizable scalar.
- How deep it goes
- Derives policy-gradient and PPO objectives through ratios, advantages, clipping, log-probabilities, and per-token implementation.
- Examples
- Uses PPO equations, per-token log-probability ratios, policy-gradient cases, reward functions, and preference-optimization losses.
- What you can do after
- Apply it via policy-gradient or PPO losses while recognizing clipping constraints and proxy-objective failure modes.
Read how Reinforcement Learning from Human Feedback explains objective function →
Graph Neural Networks in Action
A loss function is a function that quantifies the discrepancy between a model's output and the desired target.
- How it is used
- Guides graph-model training by turning prediction errors and reconstruction goals into a value the optimizer can reduce.
- How deep it goes
- Explains computation inside training loops and composite objectives, without deriving individual loss formulas.
- Examples
- Uses masked node classification and molecular graph reconstruction with predicted adjacency, features, and QED properties.
- What you can do after
- Apply it via a GNN training loop that computes loss, propagates gradients, and updates model parameters.
Read how Graph Neural Networks in Action explains objective function →
Build an AI Agent (From Scratch)
A metric is a quantitative indicator that aggregates evaluation judgments into a value trackable across cases or over time.
- How it is used
- Uses quantitative indicators to monitor agent quality, operational behavior, regressions, and improvement over time.
- How deep it goes
- Defines rubric-based aggregation and example formulas, while stopping short of mathematical optimization or implementation code.
- Examples
- Uses pass rates for answer relevancy, citation reliability, requirement compliance, latency, cost, token use, and tool-call frequency.
- What you can do after
- Operate/configure evaluation dashboards and deployment checks that expose quality regressions through trackable indicators.
Read how Build an AI Agent (From Scratch) explains objective function →
Statistics Slam Dunk
An objective function is the mathematical function or criterion that an optimization procedure seeks to minimize or maximize.
- How it is used
- Optimizes the value of an NBA free-agent roster while honoring position, player-count, salary, and age constraints.
- How deep it goes
- Defines the objective and demonstrates its lp() implementation, but does not develop the underlying optimization mathematics.
- Examples
- Uses an NBA free-agent roster, an lp() call, selected-player output, total win shares, salary, and average age.
- What you can do after
- Apply it via lpSolve to maximize win shares for a roster that satisfies explicitly specified constraints.
AI Agents in Action, Second Edition
A product metric measures business or user outcomes associated with an agent's deployed role.
- How it is used
- Uses measurable targets to improve model predictions during training and judge deployed-agent outcomes in production.
- How deep it goes
- Explains loss, backpropagation, and metric categories, but stops short of specifying an explicit mathematical objective or optimization algorithm.
- Examples
- Uses next-token prediction, task completion, escalation, conversion, resolution, latency, grounding, and user feedback as measurable examples.
- What you can do after
- Evaluate/understand whether model training reduces prediction error and whether an agent improves its intended production outcome.
Read how AI Agents in Action, Second Edition explains objective function →
Related concepts
- validation losscontrasts with · The value of a loss function computed on held-out validation data to assess a model’s predictions.
- mean squared errorincludes · Mean squared error is the arithmetic mean of the squared differences between corresponding predicted and target numerical values.
- simulated annealingused by · Simulated annealing is a stochastic optimization method that gradually reduces the probability of accepting worse solutions to escape local optima.
- training datasetmeasures · A collection of examples or observations supplied to a learning procedure to fit or adapt a model or learn its patterns or parameters.
- stressequivalent to · Stress is an MDS discrepancy measure that quantifies the difference between original dissimilarities and distances in the fitted low-dimensional representation.
- cross entropy lossincludes · Cross-entropy loss measures the expected negative log probability that a predicted distribution assigns to outcomes drawn from a target distribution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





























