F INE - GRAIN I NFERENCE ON O UT - OF -D ISTRIBUTION D ATA WITH H IERARCHICAL C LASSIFICATION
Anonymous authors
Paper under double-blind review
A BSTRACT
Machine learning methods must be trusted to make appropriate decisions in realworld environments, even when faced with out-of-distribution (OOD) samples.
Many current approaches simply aim to detect OOD examples and alert the user when an unrecognized input is given.
However, when the OOD sample significantly overlaps with the training data, a binary anomaly detection is not interpretable or explainable, and provides little information to the user.
We propose a new model for OOD detection that makes predictions at varying levels of granularity—as the inputs become more ambiguous, the model predictions become coarser and more conservative.
Consider an animal classifier that encounters an unknown bird species and a car.
Both cases are OOD, but the user gains more information if the classifier recognizes that its uncertainty over the particular species is too large and predicts “bird” instead of detecting it as OOD.
Furthermore, we diagnose the classifier’s performance at each level of the hierarchy improving the explainability and interpretability of the model’s predictions.
We demonstrate the effectiveness of hierarchical classifiers for both fine- and coarse-grained OOD tasks.
I NTRODUCTION
Real-world computer vision systems will encounter out-of-distribution (OOD) samples while making or informing consequential decisions.
Therefore, it is crucial to design machine learning methods that make reasonable predictions for anomalous inputs that are outside the scope of the training distribution.
Recently, research has focused on detecting inputs during inference that are OOD for the training distribution (Ahmed & Courville, 2020; Hendrycks & Gimpel, 2017; Hendrycks et al., 2019;
Hsu et al., 2020; Huang & Li, 2021; Lakshminarayanan et al., 2017; Lee et al., 2018; Liang et al., 2018; Liu et al., 2020; Neal et al., 2018; Roady et al., 2020; Inkawhich et al., 2022).
These methods typically use a threshold on the model’s “confidence” to produce a binary decision indicating if the sample is in-distribution (ID) or OOD.
However, binary decisions based on model heuristics offer little interpretability or explainability.
The fundamental problem is that there are many ways for a sample to be out-of-distribution.
Ideally, a model should provide more nuanced information about how a sample differs from the training data.
For example, if a bird classifier is presented with a novel bird species, we would like it to recognize that the sample is a bird rather than simply reporting OOD.
On the contrary, if the bird classifier is shown an MNIST digit then it should indicate that the digit is outside its domain of expertise.
Recent studies have shown that fine-grained OOD samples are significantly more difficult to detect, especially when there is a large number of training classes (Ahmed & Courville, 2020; Huang & Li, 2021; Roady et al., 2020; Zhang et al., 2021; Inkawhich et al., 2021).
We argue that the difficulty stems from trying to address two opposing objectives: learning semantically meaningful features to discriminate between ID classes while also maintaining tight decision boundaries to avoid misclassification on fine-grain OOD samples (Ahmed & Courville, 2020; Huang & Li, 2021).
We hypothesize that additional information about the relationships between classes could help determine those decision boundaries and simultaneously offer more interpretable predictions.
To address these challenges, we propose a new method based on hierarchical classification.
The approach is illustrated in fig.
Rather than directly outputting a distribution over all possible classes, as in a flat network, hierarchical classification methods leverage the relationships between classes to produce conditional probabilities for each node in the tree.
This can simplify the classification problem since each node only needs to distinguish between its children, which are far fewer in number (Redmon & Farhadi, 2017; Ridnik et al., 2021).
It can also improve the interpretability of the neural network (Wan et al., 2021).
For example, we leverage these conditional probabilities to define novel OOD metrics for hierarchical classifiers and make coarser predictions when the model is more uncertain.
By employing an inference mechanism that predicts at different levels of granularity, we can estimate how similar the OOD samples are from the ID set and at what node of the tree the sample becomes
OOD.
When outliers are encountered, predicting at lower granularity allows the system to convey imprecise, but accurate information.
We also propose a novel loss function for the hierarchical softmax classification technique to address the fine-grained OOD scenario.
We propose hierarchical OOD metrics for detection and create a hierarchical inference procedure to perform inference on ID and OOD samples, which improves the utility of the model.
We evaluate the method’s sensitivity to granularity under coarse- and finegrain outlier datasets using ImageNet-1K ID-OOD holdout class splits (Russakovsky et al., 2015).
Our in-depth analysis of the ID and OOD classification error cases illuminates the behavior of the hierarchical classifier and showcases how explainable models are instrumental for solving fine-grain
OOD tasks.
Ultimately, we show that hierarchical classifiers effectively perform inference on ID and OOD samples at varying granularity levels and improve interpretability in fine-grained OOD scenarios.
R ELATED W ORK
There are four main types of related works: those which focus on fine-grain out-of-distribution detection; those which emphasize scalability to large numbers of classes; those which leverage hierarchical classifiers; and those which utilize improved feature extactors.
Fine-grain OOD.
Several recent works have identified poor OOD detection performance on fine-grain datasets with current methods (Ahmed & Courville, 2020; Roady et al., 2020; Zhang et al., 2021).
Both (Zhang et al., 2021) and (Ahmed & Courville, 2020) highlight that selecting holdout classes from the original dataset is a more realistic OOD scenario that enforces detectors utilize semantically meaningful features to detect OOD samples rather than utilizing non-semantic differences between
ID and OOD datasets to achieve good performance.
Roady et al.
(2020) also explore the issue of
OOD granularity by evaluating performance across coarse- and fine-grained samples and outline a need for new methods to address fine-grained OOD detection.
These previous two works emphasize the importance of OOD granularity especially when developing solutions for real-world applications.
We expand upon these works by designing OOD detection datasets at varying levels of granularity.
We provide an in-depth analysis of performance across OOD granularity.
Scalable OOD.
Current OOD detection techniques struggle to scale to higher resolution images or to tasks with larger numbers of ID classes (Ahmed & Courville, 2020; Huang & Li, 2021; Roady et al., 2020).
Huang & Li (2021) improve upon current OOD detection techniques’ scalability by partitioning the classification task into smaller subsets of semantically similar categories, thereby reducing each decision’s complexity.
Grouping labels into exclusive subsets allows for an explicit “other” class to be added that is optimized to predict when the input is OOD for the current classifier.
This approach uses the training data from all other subsets in a similar manner to how outlier exposure uses auxiliary outlier data (Hendrycks et al., 2019).
However, Hendrycks et al.
(2019) utilize an entropy based optimization for the outliers instead of an explicit “other” class.
Huang & Li (2021) improve the scalability, but their approach is incapable of inference on ID and OOD data.
Furthermore,
Huang & Li (2021) choose 8 class groupings from WordNet without providing a systematic process of pruning the hierarchy.
As the set of ID classes grows the relationships betweeen classes becomes more complex and the decision of how to group labels becomes increasingly arbitrary.
We utilize the full WordNet hierarchy which provides natural boundaries between label subsets and systematically prune the hierarchy.
Note that our method does not use auxiliary outlier data and developing a technique for improving uncertainty estimates via auxiliary data is left for future studies.
Hierarchical classifiers.
Hierarchical classification methods have recently been exploited to improve the classifier’s scalability to extremely large label space tasks (Ridnik et al., 2021) and to enhance deep learning explainability (Wan et al., 2021).
The current work seeks to utilize these properties to improve OOD detection methods.
Ridnik et al.
(2021) utilize the WordNet hierarchy (Fellbaum, 1998) to train a classifier on Imagenet-21K including 11,221 ID classes aiming to improve pretrained model weight available for transfer learning.
Wan et al.
(2021) instead generate a binary decision tree from the learned weights of a standard softmax classifier using agglomerative clustering.
Furthermore,
Wan et al.
(2021) thoroughly analyze the hierarchical classifier’s behavior at each node in the tree to explain the network’s prediction behavior.
This method ensures that the hierarchical relationships are based on visual similarity instead of human defined semantic similarity.
However, for OOD detection tasks we find binary trees generated from pretrained model weights do not perform as well as shallower hierarchies for OOD tasks (table 4).
Furthermore, we build upon (Wan et al., 2021)’s interpretability study by utilizing the hierarchical structure to explain the common failure modes on
ID and OOD data.
Another group of techniques incorporate hierarchical structures into the feature extractor (Ahmed et al., 2016; Yan et al., 2015) or training procedure (Alsallakh et al., 2018).
In this work we do not consider specialized network architectures and training procedures because we are interested in comparing the performance of hierarchical vs. flat classification.
We demonstrate in tableand in section 3.5 the advantages of hierarchical classification for interpretable OOD.
Exploring custom hierarchical architectures is a promising area of future research to improve interpretable OOD methods.
Improved feature extractors.
Vision transformers (Kolesnikov et al., 2021) and contrastive learning (Chen et al., 2020)
methods learn improved feature extractors leading to gains in overall classification accuracy as well as transfer learning outcomes.
Recently, (Tack et al., 2020; Winkens et al., 2020) utilize a SimCLR-based (Chen et al., 2020) architecture and (Ren et al., 2021; Vaze et al., 2022) utilize
ViT (Kolesnikov et al., 2021) to improve feature representations and OOD performance.
Likewise, our hierarchical method will likely mutually benefit from learning improved feature extractors.
However, due to the significant computational resources required to train such models we leave integrating hierarchical classifiers with contrastive learning and vision transformers for future studies.
M ETHOD
We train a hierarchical softmax classifier (section 3.1) to generate path probabilities at all nodes in the hierarchy with a multi-objective loss function to optimize for classification performance and
OOD detection (section 3.2).
Path-wise probability and entropy scoring metrics replace softmax probabilities for OOD detection to incorporate model certainty along the prediction path (section 3.3).
We employ these path-wise metrics as an inference stopping criterion to generate predictions on intermediate nodes (section 3.4).
Finally, we measure hierarchical distance and accuracy to perform an in-depth analysis of model performance (section 3.5).
3. H IERARCHICAL C LASSIFICATION
We define a hierarchy, H , as a tree-structured directed acyclic graph so that there is a unique path from the root node to each leaf node.
For notation, associate each node in the tree with an integer { 0 , 1 , . .
. , N } where 0 denotes the root node.
Let par ( n ) ∈ { 0 , . . .
, n − 1 } denote the parent of node n , let anc ( n ) ⊂ { 0 , . . .
, n − 1 } be the set of all ancestors of node n , and let ch ( n ) ⊆
{ n + 1 , . .
. , N } denote the set of children of node n .
Finally, let Y ⊂ { 0 , 1 , . . .
, N } denote the set of leaf nodes (i.e. nodes for which ch ( n ) = ∅ ) and Z = { 0 , 1 , . .
. , N } \ Y be the set of internal nodes.
Each training data point has an input x i ∈ R d and a label y i ∈ Y , which is associated with a leaf node of the hierarchy.
The training distribution, D train = { ( x i , y i ) } , is comprised of tuples of input images, x i , and associated leaf nodes, y i .
For each node n in the set of internal nodes Z , we define
D n ⊆
D train to be all the samples ( x i , y i ) whose ancestors contain n .
Likewise, define D ¬ n all the examples that whose ancestors do not contain n .
Given the input x i , the network outputs probability distributions p n =
[ p n, 1 , . .
. , p n, | ch ( n ) | ] for each internal node n , where p n,j ≥ 0 and (cid:80) | ch ( n )
| j = p n,j = 1 .
In practice, we model each p n as a softmax function of the features in the penultimate layer of a neural network.
We parameterize a distribution on leaf nodes as the product of probabilities associated with each node along that path,
[Equation]
As noted by (Wan et al., 2021), path-wise probabilities allow for errors at intermediate nodes to be corrected as opposed to making “hard” decisions at each level of the tree and following the path to the prediction.
Note that the path probabilities in eq.
(1) form a proper probability distribution such that (cid:80) k ∈Y Pr( y i =
k | x i ) = 1 .
At test time, we take the network’s prediction to be the leaf node with the highest probability, ˆ y i = arg max k ∈Y Pr
( y i = k
| x i ) .
3. H IERARCHICAL OOD L OSS
To achieve high ID accuracy and reliable OOD detection we propose a weighted multi-objective loss to optimize the hierarchical classifier.
Formally, it is defined as,
[Equation]
where H [ p, q ] is the cross-entropy from p to q and par n ( y ) is the one-hot vector for the ancestor of y corresponding to node n , onehot n ( y ) =
[ 1 ( k ∈ anc ( y )) : k ∈ ch ( n )] .
The first objective optimizes the network for ID classification accuracy by applying cross-entropy to the network’s predictions Pr( k | x i ) =
[Pr( y i = k
| x i )]
k ∈Y for each sample in the training distribution,
D train (eq. (2)) 1 .
The second objective (eq. (4)) drives the probabilities at internal nodes that are not along the path from root to ground-truth node to the uniform distribution, parameterized by size, ( U ( s ) ) with cross-entropy.
This utilizes in-distribution data as outliers for all nodes in the hierarchy that are not one of its ancestors.
As in Ridnik et al.
(2021), we find that weighting the cross-entropy contribution of each internal node improves optimization.
We weight each node’s loss, eq.
(3), based on the proportion of the total number of classes ( N ) which are children of the node.
This assigns higher weight to nodes that are closer to the root of the tree as these decisions have the greatest effect downstream classification performance.
3. P REDICTION P ATH E NTROPY OOD M ETRIC
We propose prediction path based OOD scoring functions for performing OOD detection with hierarchical classifiers.
First, we propose using maximum prediction path probabilities calculated according to eq.
(1) which is hierarchical analog to max softmax probability for standard networks.
Second, we propose using either the mean path-wise entropy, H mean , or the maximum path-wise entropy, H max , as metrics for OOD detection.
Formally, these are defined as,
[Equation]
3. I NFERENCE S TOPPING C RITERION
Given a hierarchical classifier optimized over D train , we define a stopping criterion utilizing the performance statistics on the validation data.
Specifically, we select a true negative rate (TNR) on the ID data to decide our inference stopping threshold from the micro-averaged receiver operating characteristic (ROC) curve.
In practice, this TNR threshold will be determined by the specific application’s prediction fidelity requirements.
Micro-averaged ROC curves are used to generate the
TNR thresholds for each node in Z .
We utilize path probabilities Pr( n | x i ) as the threshold score.
During inference the leaf node prediction ˆ y is determined, then the prediction path anc (ˆ y ) is traversed from root to leaf.
If any of the nodes in the path do not meet the TNR threshold, the parent node is chosen as the prediction (fig. 1).
Both global path probability and node-wise probability and mean-, min-entropy were explored as TNR threshold metrics.
3. H IERARCHICAL A CCURACY AND D ISTANCE
We analyze the hierarchical classifier’s inference on ID and OOD samples with top-1 accuracy, as well as, average hierarchical distance.
The groundtruth for OOD samples is the closest ancestor that is contained within ID hierarchy.
For example, the OOD node junco in 1 is assigned the ID groundtruth node bird .
Furthermore, we consider the inference procedure’s failure modes by decomposing the hierarchy distance into two parts: (1) the prediction and (2) the groundtruth distance to their closest common parent.
Hierarchy distance is defined as the number of edges in the hierarchy between two nodes.
By recording the groundtruth and prediction distances to the closest common parent we can determine how frequently the model incorrectly predicts, overpredicts, and underpredicts for a set of inputs.
fig.
1 (bottom) depicts common error cases that are encountered and their corresponding hierarchy distances.
E XPERIMENTS 4. OOD D ATASETS
Fine-grain OOD datasets.
Some applications may face more extreme OOD examples than others.
To construct OOD detection tasks with varying degrees of difficulty, we leveraged the fact that the Imagenet-1K classes correspond to nouns in the WordNet hierarchy (Fellbaum, 1998).
We generated OOD sets by holding out subsets of Imagenet-1K classes in entire subtrees of the WordNet hierarchy.
Withholding large subtrees—those rooted at low depths of the hierarchy—leads to coarse-grained OOD detection tasks, since the held-out classes are very different from the training classes.
Holding out small subtrees—those rooted at nodes deep in the hierarchy—leads to fine-grained
OOD-detection tasks.
We created 2 datasets
Imagenet-100 and Imagenet-1K starting from a 100 class subset of Imagenet-1K classes and the full Imagenet-1K dataset.
Table 2 provides summary statistics of both Imagenet datasets.
We used the 100 class dataset, Imagenet-100, to evaluate the effects of additional fully-connected (FC) layers and hierarchy choice.
We prune the
WordNet hierarchy for this dataset by removing all nodes with a single child and manually combining semantically similar leaf nodes into groups of 5.
Figure 2 shows the hierarchy with randomly chosen coarse- and fine-grain OOD classes in red and the training classes in blue.
We used Imagenet-1K to evaluate the hierarchical classifier’s scalability to large ID datasets.
Again, we prune the WordNet hierarchy by first removing all nodes with a single child.
We then further pruned the hierarchy to a fixed number of internal nodes by iteratively pruning the node with the minimum entropy by merging its children.
We use training distribution statistics to calculate the entropy for each internal node.
However, we find that these simplified hierarchies do not improve ID accuracy or OOD performance.
Coarse-grain OOD datasets.
For further comparison to other baseline methods and analysis of farOOD data we used coarse-grain OOD datasets for baseline comparisons.
Specifically, we compared to the iNaturalist (Horn et al., 2018), SUN (Xiao et al., 2010), Places365 (Zhou et al., 2018), and
Textures (Cimpoi et al., 2014) subsets from (Wan et al., 2021).
4. M ODEL T RAINING
All models were trained from scratch as the available pretrained weights were trained on the finegrained OOD holdout classes.
We used a ResNet
(He et al., 2016) backbone for all models and trained for 90 epochs of stochastic gradient descent (SGD).
We used a learning rate of 0.1 with learning rate decay steps with a decay factor of 0.1 performed at epoch 30 and 60.
The momentum and weight decay parameters were 0.9 and 10 − 4 , respectively.
We standardized the training hyperparameters to avoid performance differences due to the optimization procedure.
4. R ESULTS
Fine-grain OOD performance We found that the hierarchical softmax classifier (HSC) outperformed baseline methods on the Imagenet-100 dataset and performs within 2% of the best performing baseline for Imagenet-1K dataset (table 6).
The hierarchical classifiers benefit from additional FC layers on top of the ResNet50 feature extractor due to the additional complexity of classifying into several disjoint sets (table 7).
This also suggests that specialized hierarchical network architectures (Ahmed et al., 2016; Yan et al., 2015; Alsallakh et al., 2018) that learn features specific to each node’s classifier may further improve OOD performance.
We assessed the effect of holdout class granularity and found that the softmax-based OOD heuristics (MSP, ODIN, and prediction path probability) are most sensitive to fine-grain OOD samples whereas MOS and path entropy metrics perform best on coarse-grain OOD as shown in table 6.
Also, we find that outlier exposure improves coarse-grain
[Table]
OOD performance across all HSC metrics.
Finally, we find that the Imagenet-100 trained ODIN detector is the best performer on the 4 far-OOD datasets table 9.
However, MOS is the best performer on iNaturalist, SUN and Places when scaling the number of ID classes to the Imagenet-1K dataset.
Hierarchy selection.
In table 4, we evaluate the sensitivity to hierarchy depth and composition for Imagenet-100 datasets with two human-defined semantic, WordNet (Fellbaum, 1998) based hierarchies and a visually-derived binary decision tree induced from the learned weights of a standard softmax classifier following the procedure from (Wan et al., 2021).
The two-level hierarchy is created using the direct parents of the leaf-nodes from WordNet.
We find that the performance across all
OOD metrics introduced in section 3.3 is comparable.
In particular, there is no apparent benefit to visually-derived hierarchies vs. human-defined semantic hierarchies.
However, we believe that the hierarchy is a critical design choice and is likely application dependent.
Specifically, the hierarchy’s class balance, depth, and alignment with visual features are important characteristics to consider.
In natural image classification domains, human-defined semantic structures may improve interpretability because they project image inputs into a human conceptual framework even though they may not perfectly represent the visual properties of the input.
Scalability to large ID datasets.
In table 6, we find that HSC classifiers are able to scale to large ID datasets.
However, the performance of the path-wise entropy based OOD detection metric H mean under-performs.
We suspect that this can be attributed to deep, imbalanced hierarchies where some branches receive extremely low weights making optimization more difficult (eq. (3)).
Indeed, we find that simplifying the hierarchy with custom pruning and a 2 level hierarchy we can regain the lost OOD performance and even outperform the best baseline table 5.
Therefore, well balanced hierarchies and models with sufficient capacity avoid this optimization problem.
A NALYSIS
Hierarchical classifiers decompose the classification problem into simpler intermediate tasks.
By analyzing the model’s confidence at each intermediate decision, we can understand where the model becomes uncertain.
Wan et al.
(2021) show that through analyzing intermediate decisions we can explain the model’s decision process to understand where the model makes mistakes and how it behaves on ambiguous labels, and we can use that insight to improve human trust in the predic- tor.
Therefore, hierarchical classifiers may greatly improve the interpretability and explainability compared to softmax classifiers.
We build off of this work by leveraging intermediate model confidence estimates to determine at what level of granularity to make a prediction.
For ID data this corresponds to making more conservative predictions when the model is uncertain, based on the intuition that a correct, less specific prediction improves the user’s confidence in a model than an incorrect, more specific prediction.
Similarly, for OOD data the same method can indicate exactly where the sample diverges from the training distribution and therefore can predict the sample’s parent class, allowing the user to make more informed decisions in the face of novel inputs.
5. T HRESHOLDING TO R EDUCE F ALSE -P OSITIVES
First, we aim to understand the effects of OOD data on the hierarchical classifier’s performance and if thresholding is effective for detecting and predicting OOD samples.
We plot the micro-ROC curves (fig. 3) for 4 synsets each corresponding to a separate classification decision in the hierarchy.
The “artifact”, “dog” and “bird” synsets include one or more OOD samples and the “ball” synset does not have any corresponding OOD samples (see fig. 2).
Notice in Figure 3 that when adding the activations of the OOD data (“OOD” curve) the number of false-positives increases and AUROC drops compared to the ID-only curve because the OOD data is being predicted more confidently than some ID data.
This occurs across all synsets in the hierarchy even in the “ball” synset that does not contain any OOD descendants.
However, when we employ a path-wise probability based threshold at 99% TNR on the training data (“THR” curves in fig. 3), the performance is recovered in all synsets.
The micro-ROC curves for all synsets is displayed in fig.
5. OOD I NFERENCE P ERFORMANCE
Next, we compare path-wise and node-wise thresholding methods (section 3.4).
In path-wise thresholding, a global uncertainty threshold is set and the prediction is made at the deepest node that meets the threshold.
In the node-wise method, a threshold is set for each internal node to determine if the node is certain enough to make a prediction.
On the Imagenet-100 dataset, we achieve 73% accuracy on the OOD samples while maintaining 74%
ID accuracy using a path-wise probability threshold chosen at 95% TNR as witnessed by the blue line in Figure 10.
In fig.
4, we plot the ID and OOD hierarchy distance over the TNRs used to set the prediction threshold to analyze the inference method’s behavior.
Note that the ODIN baseline is only capable of predicting a leaf-node or not predicting at all.
This leads to the larger OOD hierarchy distance across the TNR spectrum (fig. 4 grey), as well as, the faster decline in ID performance compared to the node-wise thresholding method (fig.
4 black vs green).
Figure 10 further shows the limitations of binary OOD detectors as they are incapable of predicting on OOD samples.
The large step changes and deviation of path-wise thresholding in Figure 10 and Figure 4 reflect that the path-wise thresholds cause the network to predict at increasingly coarse nodes as the confidence degrades with increasing depth (i.e. specificity, see eq.
Whereas the behavior of the node-wise thresholding technique changes the required certainty at all nodes in the hierarchy leading to smoother behavior and tighter standard deviations in the green and red lines in Figure 4 and Figure 10.
When the distribution of OOD classes is balanced across granularity levels, the node-wise inference technique greatly outperforms the path-wise technique due to the step wise nature of the path-wise technique (figs.
6 to 9).
Accuracy is a binary indicator of performance for each sample which is well suited to softmax and other flat classifiers that do not capture the relationships between classes.
However, for inference on
OOD data and prediction under uncertainty, hierarchy distance is useful as a measure of the semantic differences between the prediction is to the groundtruth.
We show that OOD average hierarchy distance consistently decreases and the ID average hierarchy distance remains relatively constant (fig. 4, bottom).
While the ID accuracy drops from 82.75% to 74.46% at the 95% TNR node-wise threshold, the average hierarchy distance decreases from 0.4045 to 0.4005 (fig.
4 bottom right).
This indicates that the increase in hierarchy distance from the ∼ 8% drop in ID accuracy is counteracted by predicting the ∼ 17% of original error cases at a lower specificity, thereby reducing the average hierarchy distance.
Therefore, by allowing the hierarchical classifier to predict with less specificity, we can improve the overall prediction quality by removing uncertain leaf node predictions.
5. I NFERENCE E RROR A NALYSIS
Error analysis is crucial to interpreting deep learning methods (Wan et al., 2021).
We find that analyzing the hierarchy distance between prediction and groundtruth nodes for ID and OOD samples illuminates the common pathologies of our inference method fig.
Specifically, we find that both the path- and node-wise OOD errors commonly occur from over-prediction indicated by the concentration of samples along the prediction axis with a ground-truth distance of 0.
Conversely, the
ID data is generally under-predicted by 1 node indicating that the most uncertain ID samples are being predicted at a coarser granularity fig.
In the standard ROC based metrics, the OOD samples with a greater certainty than the leaf-level ID predictions would be considered false-positives.
We believe that analyzing the hierarchical distance is a more appropriate compared to standard AUROC metrics for fine-grained OOD scenarios as it allows for predicting uncertain ID samples at a coarser level which is likely the desired behavior when the ID and OOD are very closely related.
C ONCLUSION
In this work, we propose a method for performing inference on OOD samples with hierarchical classifiers.
We argue that in the fine-grain OOD scenario, detecting a sample as OOD is often not the optimal behavior when the sample is a descendant of an ID class.
Hierarchical inference also improves ID prediction when the model’s uncertainty is large and a more certain, less precise prediction is available.
Hierarchical classification enforces that intermediate predictions are made that can be directly analyzed to better interpret, explain, and validate the model’s decisions prior to deployment.
We provide empirical evidence to support these claims and consider hierarchical inference to be a promising direction for future research for creating trusted real-world machine learning systems.
A A PPENDIX A. C OMPUTE RESOURCES
All experiments were run on an internal compute cluster with nodes containing 8 NVIDIA RTX
A5000 GPUs.
Imagenet 100 experiments were trained on 1 GPU for 90 epochs which completed in ∼ 8 hours for the longest running experiments.
Imagenet 1K experiments were trained on 2 GPUs with data parallelization.
Training for the Imagenet 1K’s longest running experiments lasted ∼ 52.
hours.
A. H IERARCHY S TATISTICS
[Figure]
[Table] [Figure] [Table] [Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
A. I MAGENET 100 H IERARCHY E XPERIMENTS
[Table]
A. I MAGENET 1K H IERARCHY E XPERIMENTS
[Table]
A. I MAGENET 100 AND I MAGENET 1K A DDITIONAL OOD M ETRICS
[Table]
[Figure] [Figure]
I MAGENET 1K HIERARCHY DISTANCE AND ACCURACY
[Figure] [Figure]
[Figure] [Figure]
A. H IERARCHICAL PERFORMANCE BY DEPTH
Hierarchical classifiers provide interpretable decisions by introducing additional classification tasks at each internal node in the hierarchy.
While this allows for improved interpretability and ability to perform verification, each additional classifier is another potential point of failure.
We mitigate this by using “soft” decisions by using path probabilities for predictions instead of traversing the hierarchy in a top-down fashion akin to a decision tree as suggested by Wan et al.
We plot percentage of classification errors that occur at each hierarchy depth (figs.
14 to 16) and compare the performance of hierarchical classifiers to a flat classifier.
To determine the depth of the error we follow the prediction path in a top-down fashion and record where the depth of the node where the error occurs.
For example, for the Imagenet 100 dataset, if a sample’s groundtruth is “house finch” and the classifier predicts “puffer”, then the error was made by the “vertebrate” node’s classifier and the error depth is 2 (see fig. 2).
Note that this can be performed for any prediction regardless of whether the classifier can only produce leaf node predictions.
We calculate OOD error depths by assigning each OOD sample a ground truth to be the deepest internal node that is contained in the set of ID classes as we do when calculating hierarchical accuracy and hierarchical distance (section 5.2).
As we are trying to evaluate the prediction accuracy and not the inference mechanism, we calculate an “oracle” accuracy for these plots.
Specifically, an OOD prediction is “correct” if its path contains the
OOD groundtruth path and predicted nodes that are at deeper levels than the groundtruth are ignored.
For example, in the Imagenet 100 dataset “junco” is OOD and its groundtruth value is assigned to its closest ancestor that is contained in the ID set which is “bird”.
For the purposes of these plots, if a classifier predicts “house finch” whose path also contains “bird”, the prediction is considered to be correct (see fig. 2).
In figs.
14 to 16 it is clear that hierarchical and flat classifiers tend to misclassify similar difficult samples and have similar ID and OOD accuracy performance.
Also, note that when the OOD accuracy performance drops in the Imagenet 1K dataset (fig. 16), the hierarchical classifiers begin to outperform the flat classifier.
Since we keep the feature extractor the same between hierarchical and flat classifiers it is perhaps not surprising that they learn similar feature sets that lead to similar leaf node mistakes.
The main focus of the current work is to compare the OOD performance of hierarchical versus flat models.
This restricts our ability to explore additional hierarchical feature extractors as it would not allow for direct performance comparisons.
An extension of the current work would explore hierarchical feature extractors to improve each node’s classification performance by learning additional features that are optimized to distinguish between a given node’s children.
Another interesting future direction is to identify poorly performing internal nodes’ classifiers during training and explicitly attempt to improve their performance through adapting the nodes’ weights (eq.
(3)) or by developing other techniques.
A. F ULLY C ONNECTED H EAD E XPERIMENTS
[Table]
A. S UPPLEMENTAL OOD GRANULARITY PERFORMANCE
[Table]
A. P ERFORMANCE ON FAR -OOD BENCHMARKS
[Table]