In the context of neural network interpretability, the directional derivative measures the instantaneous sensitivity of a class logit to a Concept Activation Vector (CAV). Formally, if ( f(x) ) is the logit for a class and ( v_c ) is a unit CAV representing a concept, the directional derivative is ( \nabla f(x) \cdot v_c ). This scalar value captures how strongly and in which direction the prediction responds to the abstract concept encoded by ( v_c ).
Glossary
Directional Derivative

What is Directional Derivative?
The directional derivative quantifies the rate of change of a model's prediction score with respect to an infinitesimal shift in the input's activation along a specific concept vector direction.
This computation is the mathematical foundation of the Testing with CAVs (TCAV) framework. By calculating the directional derivative for multiple inputs, TCAV derives a sensitivity score that quantifies a model's overall reliance on a user-defined concept. A statistically significant, positive directional derivative indicates that amplifying the concept's activation increases the model's confidence in the target class, providing a quantitative bridge between high-level semantics and internal network geometry.
Key Characteristics of the Directional Derivative
The directional derivative quantifies how a model's prediction score changes as its internal activations are infinitesimally shifted along a specific concept vector direction, forming the mathematical backbone of concept-based interpretability.
Mathematical Definition
For a class prediction score ( f_l(x) ) at layer ( l ), the directional derivative with respect to a concept vector ( v_C ) is defined as:
( S_{C,k,l}(x) = \nabla h_{l,k}(f_l(x)) \cdot v_C )
- ( h_{l,k} ) is the logit function for class ( k ) from layer ( l )
- ( \nabla h_{l,k} ) is the gradient of that logit with respect to activations
- ( v_C ) is the unit Concept Activation Vector (CAV)
- The dot product yields a scalar sensitivity score
- A positive value indicates the concept increases the class prediction; a negative value decreases it
Role in TCAV Framework
The directional derivative is the core computational mechanism within Testing with CAVs (TCAV). It transforms abstract concept vectors into quantifiable metrics:
- For each input ( x ) in a dataset, TCAV computes the directional derivative toward a concept vector
- The fraction of inputs with a positive directional derivative becomes the TCAV score
- This score represents how sensitive the model's prediction is to the concept
- A TCAV score of 0.8 means 80% of inputs show increased class probability when activations shift toward the concept
- Enables quantitative hypothesis testing about what a model has learned
Geometric Interpretation
In the high-dimensional activation space, the directional derivative has a clear geometric meaning:
- The gradient ( \nabla h ) points in the direction of steepest ascent for the class score
- The directional derivative measures the projection of this gradient onto the concept vector
- If the gradient and concept vector are aligned (cosine similarity near 1), the derivative is large and positive
- If they are orthogonal (cosine similarity near 0), the concept has no local influence
- If they are opposed (cosine similarity near -1), the concept actively suppresses the prediction
- This projection reveals which concepts the model uses as evidence for or against a class
Statistical Validation
Raw directional derivatives require statistical testing to ensure the concept signal is not an artifact:
- TCAV computes directional derivatives for the true concept vector and for multiple random vectors
- A two-sided t-test compares the distribution of sensitivity scores
- The null hypothesis: the concept vector produces scores indistinguishable from random directions
- A concept passes validation only if the p-value is below a threshold (typically 0.05)
- This guards against spurious correlations where random noise directions accidentally align with gradients
- Only statistically significant concepts are considered genuinely learned by the model
Layer-Specific Analysis
Computing directional derivatives at different network layers reveals where concepts are encoded:
- Early layers: Directional derivatives often capture low-level concepts like textures, edges, or colors
- Middle layers: Begin encoding composite concepts like object parts and shapes
- Final layers: Encode high-level semantic concepts like object categories and abstract attributes
- A concept may have a strong directional derivative at one layer but be absent at another
- This layer-wise profiling maps the hierarchy of abstraction in the network
- Engineers use this to identify which layers to probe for specific concept auditing tasks
Practical Computation
Implementing the directional derivative requires careful numerical handling:
- Compute the gradient of the target class logit with respect to activations at the chosen layer using backpropagation
- Normalize the CAV to a unit vector to ensure comparability across concepts
- The dot product ( \nabla h \cdot v_C ) is computed per input in a batch
- For stochastic settings, average gradients over multiple forward passes
- Libraries like TensorFlow and PyTorch provide automatic differentiation for efficient gradient computation
- The result is a scalar tensor representing instantaneous sensitivity at the current activation point
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Addressing common questions about how directional derivatives quantify a model's sensitivity to high-level concepts, enabling rigorous, human-auditable explanations of neural network decisions.
A directional derivative quantifies the instantaneous rate of change of a model's prediction score with respect to an infinitesimal shift in the input's activation along a specific concept vector direction. In the context of Concept Activation Vectors (CAVs) and Testing with CAVs (TCAV), it measures how sensitive a class prediction is to the presence of a high-level, human-understandable concept. Mathematically, for a class logit (y_k) and a concept vector (v_l) in the activation space of a layer, the directional derivative (S_{k,l}(x)) is computed as the dot product of the gradient of (y_k) with respect to the activations and the unit concept vector. This value forms the core of the sensitivity metric, directly indicating whether increasing the concept's presence pushes the prediction towards or away from the target class.
Related Terms
The directional derivative is the fundamental mathematical operation underpinning concept-based explanations. These related terms define the ecosystem of vectors, sensitivity measurements, and statistical validations required to audit neural network activations.
Concept Activation Vector (CAV)
A vector in a neural network's activation space that represents a high-level, human-understandable concept. It is derived by training a linear classifier to distinguish between examples of the concept and random counterexamples. The CAV defines the precise direction along which the directional derivative is computed, transforming abstract semantic ideas into mathematical operations.
Sensitivity
In concept-based explanations, sensitivity measures how much a model's prediction for a class changes in response to perturbations along the direction of a concept vector. It is the scalar output of the directional derivative operation. A high sensitivity score for the concept 'stripes' on a 'zebra' class indicates the model relies heavily on that visual attribute.
Statistical Significance Testing
A procedure within TCAV that uses a two-sided t-test to determine if the sensitivity scores for a concept are significantly different from those obtained using random vectors. This ensures the concept is not an artifact of noise. Only concepts with a low p-value after multiple comparison correction are considered valid explanations.
Activation Space
The high-dimensional vector space formed by the outputs of a specific layer within a neural network. Individual directions in this space can encode semantically meaningful concepts. The directional derivative is computed within this space, measuring the rate of change of the output logit as we move along a concept vector from a given input's activation point.
Concept Subspace Projection
The mathematical operation of decomposing an activation vector into components that align with a concept vector and components that are orthogonal to it. This projection is a prerequisite for concept erasure and intervention. It relies on the same geometric principles as the directional derivative, isolating the specific contribution of a concept direction.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us