# Normalizing Flows for Out-of-Distribution Detection: Application to Coronary Artery Segmentation
## 3 Results and Discussion
### Inspecting the Flows  
The main hypothesis in [28] is that, in hierarchical VAEs, the lowest latent variables \"learn generic features that can be used to describe a wide range of data\" and thus OoD data can achieve high likelihoods \"as long as the learned low-level features are appropriate\". It is further suggested that \"OOD data are in-distribution with respect to these low-level features, but not with respect to semantic ones\". Inspired by the hierarchical likelihood bounds approach in [28], we inspected the progressive transformation of mask-perturbed samples as they are passed through the sequence of coupling layers inside the NF models (i.e., going in the forward direction from \(x\in X\) to \(z\in Z\)). We recorded the likelihood of the first factored out embeddings (termed \(z_{bottom}\)) after the first splitting operation and their associated logDet values at that stage. We computed pseudo-likelihood values, associated to these \"bottom features\", by ignoring the rest of the computational chain and the part of the embeddings which were not factored  
Figure 14: Three samples (pairs of lumen image and segmentation mask) generated by the proposed network (**right**) and by the baseline model (**left**). out (termed \(z_{top}\)). We also computed pseudo-likelihood values associated with the \"top features\", i.e., by summing the likelihood (under the prior) of embeddings \(z_{top}\) and the updates to logDet done at stages after the first splitting operation. Intuitively, the \"bottom features\" operate at a smaller field-of-view and tend to capture more local patterns, while the \"top features\" are built based on the \"bottom features\" and at larger fields-of-views, therefore being able to access the global semantic content of a sample. Formally, the two pseudo-likelihoods are computed as in Equation (4):  
\[ \begin{split}\mathcal{L}_{bottom}&=\ln(p(z_{ bottom}))+\ln(|\text{det}(\
abla(f_{1}\circ f_{2}\circ\ldots\circ f_{k}))|)\\ \mathcal{L}_{top}&=\ln(p\big{(}z_{top}\big{)})+\ln(| \text{det}(\
abla(f_{k+1}\circ f_{k+2}\circ\ldots\circ f_{M}))|)\end{split}  \tag{4}\]  
where \(M\) is the number of layers in the NF model and \(k\) is the index of the splitting layer which factored out \(z_{bottom}\) and retained \(z_{top}\) for the upstream layers. Because the chosen prior distribution is a diagonal multivariate Gaussian, the sum of \(\mathcal{L}_{bottom}\) and \(\mathcal{L}_{top}\) yields exactly \(\ln(p(x))\). Employing models trained only on original (unperturbed) data, we computed AuRoC values for the two pseudo-likelihoods when applying perturbations of increasing severity and compared performances to the standard case where the regular log-probabilities are used to discriminate OoD samples. Figure 15 shows the AuRoC values for the baseline and proposed models when detecting mask translations in various directions. For the baseline model, the bottom features have worse performance in detecting outliers, while the top features perform better than regular log-probs. This observation is in line with the hypothesis in [28], that higher level latent variables can better discriminate through semantic content, while lower level latents would yield similar likelihoods for OoD data if textures appear to be in-distribution. However, the proposed model shows consistent performance across the top and bottom level features and regular log-probabilities. This suggests that even at the first spatial scale, the novel coupling layers try to capture semantic features instead of local spatial correlations and that the inductive bias of this coupling layer is better suited for OoD detection than regular affine coupling layers (as used in [10] or [11]). Inspecting the proposed model also on mask-morphing or mask-zooming perturbations reveals the same behavior. However, despite the fact that pseudo-likelihoods of bottom-features exhibit similar OoD detection performance as regular log-probs, the network architecture cannot be truncated to use a smaller number of spatial scales.