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LJaCp5JIUY9FBT1WsLbQhrDZbtqlm03YnRRK6D/x4kERr/4Tb/4bt20O2vpg4PHeDDPzwlRwDa77bZXW1jc2t8rb9s7u3v6Bc3j0pJNMUdaiiUhUJySaCS5ZCzgI1kkVI3EoWDsc3cz89pgpzRP5CJOU+TEZSB5xSsBIgeNUoyDvwZABmdrVO/s2cCpuzZ0DrxKvIBVUoBk4X71+QrOYSaCCaN313BT8nCjgVLCp3cs0SwkdkQHrGipJzLSfzy+f4qpR+jhKlCkJeK7+nshJrPUkDk1nTGCol72Z+J/XzSC68nMu0wyYpItFUSYwJHgWA+5zxSiIiSGEKm5uxXRIFKFgwrJNCN7yy6vk6bzmXdTqD/VK47qIo4xO0Ck6Qx66RA10j5qohSgao2f0it6s3Hqx3q2PRWvJKmaO0R9Ynz+485Js</latexit>
D
(a) Progressive Counterfactual
Explainer (PCE)
Condition
(b) Augmented by Counterfactual
Explanation (ACE)
(c) Fine-tuning with
ACE
<latexit sha1_base64="CctnbZwlcylFZr8ejmxXw4Z1+Y8=">AAAB+XicbVBNS8NAEN3Urxq/oh69LJaCp5JIUY9FBT1WsLbQhrDZbtqlm03YnRRK6D/x4kERr/4Tb/4bt20O2vpg4PHeDDPzwlRwDa77bZXW1jc2t8rb9s7u3v6Bc3j0pJNMUdaiiUhUJySaCS5ZCzgI1kkVI3EoWDsc3cz89pgpzRP5CJOU+TEZSB5xSsBIgeNUoyDvwZABmdrVO/s2cCpuzZ0DrxKvIBVUoBk4X71+QrOYSaCCaN313BT8nCjgVLCp3cs0SwkdkQHrGipJzLSfzy+f4qpR+jhKlCkJeK7+nshJrPUkDk1nTGCol72Z+J/XzSC68nMu0wyYpItFUSYwJHgWA+5zxSiIiSGEKm5uxXRIFKFgwrJNCN7yy6vk6bzmXdTqD/VK47qIo4xO0Ck6Qx66RA10j5qohSgao2f0it6s3Hqx3q2PRWvJKmaO0R9Ynz+485Js</latexit>
D
<latexit sha1_base64="7apuN+avVYTyP+Lc9vItwT4hk/E=">A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rkJzkmTcLJNflD/pE758b569w7D0+tJWfm+UJelfP4H3W/rmM=</latexit>
f✓+
<latexit sha1_base64="L1kc6coMlIhaFDyvnvtp6tHgGeg=">AAACSnicbVBNSysxFM1Unx/jV9Wlm2AZqDwpMyLqUlTQpYJVodMOmfTWBpOZIbkjLUN/nxtX7vwRb/MWirgxrUX8uhByOOeem5sTZ1IY9P1HpzQx+WdqembWnZtfWFwqL69cmDTXHOo8lam+ipkBKRKoo0AJV5kGpmIJl/HN4VC/vAVtRJqcYz+DpmLXiegIztBSUZl5nagIsQvIBq537HpHrtdrCdfjLUFDIxQNEXpY1K0p1arqbwYbtrEXFXx4tQoxGMGPKfQvDY9A2nHVkLdT3IjKFb/mj4r+BMEYVMi4TqPyQ9hOea4gQS6ZMY3Az7BZMI2CSxi4YW4gY/yGXUPDwoQpMM1iFMWAepZpU7uqPQnSEfvZUTBlTF/FtlMx7Jrv2pD8TWvk2NlrFiLJcoSEvz/UySXFlA5zpW2hgaPsW8C4FnZXyrtMM442fdeGEHz/8k9wsVULdmrbZ9uV/YNxHDNkjayTKgnILtknJ+SU1Aknd+QfeSLPzr3z33lxXt9bS87Ys0q+VGnyDeL4sAE=</latexit>
f✓+(·)
Pre-trained Classifier
(d) Improved classifier
with
reject option
<latexit sha1_base64="qFCE1Fw72Vo5Fquk8yBJdvxOzw0=">AAAB9HicbVDLTgJBEJzFF64v1KOXiYTEE9k1RD0SPegRE0ES2JDZoRcmzD6c6SUhG77DiweN8erHePNvHGAPClbSSaWqO91dfiKFRsf5tgpr6xubW8Vte2d3b/+gdHjU0nGqODR5LGPV9pkGKSJookAJ7UQBC30Jj/7oZuY/jkFpEUcPOEnAC9kgEoHgDI3kVYJe1sUhIJvat71S2ak6c9BV4uakTHI0eqWvbj/maQgRcsm07rhOgl7GFAouYWp3Uw0J4yM2gI6hEQtBe9n86CmtGKVPg1iZipDO1d8TGQu1noS+6QwZDvWyNxP/8zopBldeJqIkRYj4YlGQSooxnSVA+0IBRzkxhHElzK2UD5liHE1OtgnBXX55lbTOq+5FtXZfK9ev8ziK5ISckjPikktSJ3ekQZqEkyfyTF7JmzW2Xqx362PRWrDymWPyB9bnDxWpkao=</latexit>
<latexit sha1_base64="aaG3jQtGm+tnIfNq68KwIp3YMm0=">AAACLHicbVBNS8NAEN34bfyqevSyWAIKUhIR9Sgq6FHBqtDUsNlO7dLdJOxOpCX0B3nxrwjiQRGv/g43tQe/Hiz7ePOGmXlxJoVB3391xsYnJqemZ2bdufmFxaXK8sqlSXPNoc5TmerrmBmQIoE6CpRwnWlgKpZwFXePyvrVHWgj0uQC+xk0FbtNRFtwhlaKKkdeOypC7ACygeuduN6x6/VcfiNoaISiIUIPi7rtSLXa8LeCTevqRQUvv5tCDEoaVap+zR+C/iXBiFTJCGdR5SlspTxXkCCXzJhG4GfYLJhGwSUM3DA3kDHeZbfQsDRhCkyzGB47oJ5VWtTuY1+CdKh+7yiYMqavYutUDDvmd60U/6s1cmzvNwuRZDlCwr8GtXNJMaVlcrQlNHCUfUsY18LuSnmHacbR5uvaEILfJ/8ll9u1YLe2c75TPTgcxTFD1sg62SAB2SMH5JSckTrh5J48khfy6jw4z86b8/5lHXNGPavkB5yPT+S8pac=</latexit>
ci⇠Uniform(0,1)
Figure 2. (a) Given a pre-trained classifier fθ, we learn a c-GAN based progressive counterfactual explainer (PCE) G(x,c), while keeping fθfixed. (b)
The trained PCE creates counterfactually augmented data. (c) A combination of original training data and augmented data is used to fine-tune the classifier,
fθ+∆. (d) The discriminator from PCE serves as a selection function to detect and reject OOD data.
Our goal is to improve the pre-trained classifier fθsuch
that the revised model provides better uncertainty estimates,
while retaining its original predictive accuracy. To enable
this, we follow a two step approach. First, we fine-tune
fθon counterfactually augmented data. The fine-tuning
helps in widening the classification boundary of fθ, result-
ing in improved uncertainty estimates on ambiguous and
near-OOD samples. Second, we use a density estimator to
identify and reject far-OOD samples.
We adapted previously proposed PCE [58] to generate
counterfactually augmented data. We improved the exist-
ing implementations of PCE, by adopting a StyleGANv2-
based backbone for the conditional-GAN in PCE. This al-
lows using continuous vector fθ(x)as condition for con-
ditional generation. Further, we used the discriminator of
cGAN as a selection function to abstain revised fθ+∆ from
making prediction on far-OOD samples (see Fig. 2).
Notation: The classification function is defined as fθ:
Rd→RK, where θrepresents model parameters. The
training dataset for fθis defined as D={X,Y}, where x∈
Xrepresents an input space and y∈ Y ={1,2,··· , K}is
a label set over Kclasses. The classifier produces point es-
timates to approximate the posterior probability P(y|x,D).
2.1. Progressive Counterfactual Explainer (PCE)
We designed the PCE network to take a query image
(x∈Rd) and a desired classification outcome (c∈RK) as
input, and create a perturbation of a query image (ˆ
x) such
that fθ(ˆ
x)≈c. Our formulation, ˆ
x=G(x,c)allows us to
use cto traverse through the decision boundary of fθfrom
the original class to a counterfactual class. Following pre-
vious work [34, 58, 59], we design the PCE to satisfy the
following three properties:
1. Data consistency: The perturbed image, ˆ
xshould be
realistic and should resemble samples in X.
2. Classifier consistency: The perturbed image, ˆ
x
should produce the desired output from the classifier
fθi.e.fθ(G(x,c)) ≈c.
3. Self consistency: Using the original classification de-
cision fθ(x)as condition, the PCE should produce a
perturbation that is very similar to the query image,
i.e.G(G(x,c), fθ(x)) = xand G(x, fθ(x)) = x.
Data Consistency: We formulate the PCE as a cGAN that
learns the underlying data distribution of the input space X
without an explicit likelihood assumption. The GAN model
comprised of two networks – the generator G(·)and the
discriminator D(·). The G(·)learns to generate fake data,
while the D(·)is trained to distinguish between the real and
fake samples. We jointly train G, D to optimize the follow-
ing logistic adversarial loss [12],
Ladv(D, G) = Ex[log D(x) + log(1 −D(G(x,c)))] (1)
The earlier implementations of PCE [58], have a hard
constraint of representing the condition cas discrete vari-
ables. fθ(x)is a continuous variable in range [0,1]. We
adapted StyleGANv2 [1] as the backbone of the cGAN.
This formulation allow us to use c∈RKas condition.
We formulate the generator as G(x,c) = g(e(x),c),
a composite of two functions, an image encoder e(·)and
a conditional decoder g(·)[1]. The encoder function e:
X → W+, learns a mapping from the input space Xto an
extended latent space W+. The detailed architecture is pro-
vided in Fig. 3. Further, we also extended the discriminator
network D(·)to have auxiliary information from the classi-
fier fθ. Specifically, we concatenate the penultimate activa-
tions from the fθ(x)with the penultimate activations from
the D(x), to obtain a revised representation before the final
fully-connected layer of the discriminator. The detailed ar-
chitecture is summarized in supplementary material (SM).