I MPROVING VAE S ’ R OBUSTNESS TO A DVERSARIAL A TTACK
A BSTRACT
Variational autoencoders (VAEs) have recently been shown to be vulnerable to adversarial attacks, wherein they are fooled into reconstructing a chosen target image.
However, how to defend against such attacks remains an open problem.
We make signiﬁcant advances in addressing this issue by introducing methods for producing adversarially robust VAEs.
Namely, we ﬁrst demonstrate that methods proposed to obtain disentangled latent representations produce VAEs that are more robust to these attacks.
However, this robustness comes at the cost of reducing the quality of the reconstructions.
We ameliorate this by applying disentangling methods to hierarchical VAEs.
The resulting models produce high–ﬁdelity autoencoders that are also adversarially robust.
We conﬁrm their capabilities on several different datasets and with current state–of–the–art VAE adversarial attacks, and also show that they increase the robustness of downstream tasks to attack.
I NTRODUCTION
Variational autoencoders (VAEs) are a powerful approach to learning deep generative models and probabilistic autoencoders (Kingma & Welling, 2014; Rezende et al., 2014).
However, previous work has shown that they are vulnerable to adversarial attacks (Tabacof et al., 2016; Gondim-Ribeiro et al., 2018; Kos et al., 2018): an adversary attempts to fool the VAE to produce reconstructions similar to a chosen target by adding distortions to the original input, as shown in Fig 1.
This kind of attack can be harmful when the encoder’s output is used downstream, as in Xu et al.
; Kusner et al.
Theis et al.
; Townsend et al.
; Ha & Schmidhuber (2018); Higgins et al.
(2017b).
As
VAEs are often themselves used to protect classiﬁers from adversarial attack (Schott et al., 2019;
Ghosh et al., 2019), ensuring VAEs are robust to adversarial attack is an important endeavour.
Despite these vulnerabilities, little progress has been made in the literature on how to defend VAEs from such attacks.
The aim of this paper is to investigate and introduce possible strategies for defence.
We seek to defend VAEs in a manner that maintains reconstruction performance.
Further, we are also interested in whether methods for defence increase the robustness of downstream tasks using VAEs.
Our ﬁrst contribution is to show that regularising the variational objective during training can lead to more robust VAEs.
Speciﬁcally, we leverage ideas from the disentanglement literature (Mathieu et al., 2019) to improve VAEs’ robustness by learning smoother, more stochastic representations that are less vulnerable to attack.
In particular, we show that the total correlation (TC) term used to encourage independence between latents of the learned representations (Kim & Mnih, 2018;
Chen et al., 2018;
Esmaeili et al., 2019) also serves as an effective regulariser for learning robust VAEs.
Though a clear improvement over the standard VAE, a severe drawback of this approach is that the gains in robustness are coupled with drops in the reconstruction performance, due to the increased regularisation.
Furthermore, we ﬁnd that the achievable robustness with this approach can be limited (see Fig 1) and thus potentially insufﬁcient for particularly sensitive tasks.
To address this, we apply
TC–regularisation to hierarchical VAEs.
By using a richer latent space representation than a standard
VAE, the resulting models are not only more robust still to adversarial attacks than single-layer models with TC regularisation, but can also provide reconstructions which are comparable to, and often even better than, the standard (unregularised, single-layer) VAE.
[Table]
Improving VAEs’ Robustness to Adversarial Attack correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial at- tacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s (a) (b) output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro
Improving VAEs’ correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro
Improving VAEs’ Robustness to Adversarial Attack correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s (a)
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro
Improving VAEs’ Robustness to Adversarial Attack correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop
VAEs that are more resilient still.
model, Seatbelt , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s (a)
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro                                                       correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure
We can see that, by adding a well-chosen distortion (Dis- right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original middle) to a somewhat blurry version of
Wintour
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro                                                       as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =  D KL ( q  ( z | x ) || p ✓ ( x , z )) =
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro                                                       correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x and latent variables z : p ✓ ( x , z ) = p ✓ ( x | z ) p ( z ) where p ( z ) = N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro
Improving VAEs’ Robustness to Adversarial Attack correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
output.
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro                                                       correlation penalty as being regularised VAEs .
Leveraging the insight that regularised VAEs are robust to adversarial attacks, we develop a class of hierarchical
VAEs that are more resilient still.
Our model, Seatbelt-VAE , provides both robustness to adversarial attack, and higher quality reconstructions, relative to single layer regularised
VAEs.
We show that regularised hierarchical VAEs, without our proposed extensions, are not robust to adversarial attack.
See Figure 1 for a demonstration of how adversarial attacks are highly effective on vanilla VAEs, less effective on regularised VAEs and close to ineffective on our proposed
Seatbelt-VAE.
Thus our key contributions are: • A demonstration that regularised VAEs, trained with an up-weighted total correlation, are signiﬁcantly more robust to adversarial attacks than vanilla VAEs.
• We introduce a hierarchical VAE, the Seatbelt-VAE, that provides further robustness to adversarial attack.
• New connections between robustness, disentangling and adversarial attack, linked through regularisation.
Background 2.1.
Variational Autoencoders
Variational autoencoders (VAEs) are a deep extension of factor analysis suitable for high-dimensional data like images (Kingma & Welling, 2013; Rezende et al., 2014).
They have a joint distribution over data x
and latent variables z : p ✓ ( x , z ) =
p ✓ ( x | z ) p ( z ) where p ( z ) =
N (0 , I ) and p ✓ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters ✓ .
As exact inference is intractable for this model, in a
VAE we perform amortised stochastic variational inference.
By introducing a variational posterior distribution over the latent variables q  ( z | x ) =
N ( µ  ( x ) , ⌃  ( x )) , we can perform gradient ascent on the evidence lower bound (ELBO)
L ( x ) =
D KL ( q  ( z | x ) ||
p ✓ ( x , z ))
=
E q  ( z | x ) log p ✓ ( x | z )  D KL ( q  ( z | x ) || p ( z ))
 log p ( x ) w.r.t.both ✓ and  jointly, using the reparameterisation trick to take gradients through Monte Carlo samples from q  ( z | x ) .
Attacks on VAEs
In an adversarial attack an agent is trying to manipulate the behaviour of some machine learning model towards a goal of their choosing.
Commonly in deep learning this would be fooling a classiﬁer to misclassify an image through adding a small perturbation (Akhtar & Mian, 2018; Gilmer et al., 2018).
Very small changes in input, of little importance to the human eye, can produce large changes in the model’s
[Figure]
Attacks on VAEs have been proposed in Tabacof et al.
(2016); Gondim-Ribeiro et al.
; Kos et al.
The adversary wants draws from the model to be close to a target image when given a distorted image as input.
See Figure 1.a) for an example of a successful attack on a vanilla VAE.
Here we are trying to turn Hugh Jackman (Original, top left) into Anna Wintour (Target, bottom left).
We can see that, by adding a well-chosen distortion (Distortion, bottom right), the reconstruction of Jackman goes from looking like a somewhat blurry version of the input (Original rec., top middle) to a somewhat blurry version of
Wintour (Adversarial rec., bottom middle).
The adversary has achieved their goal.
The current most effective mode of attack on VAEs, the latent space attack (Tabacof et al., 2016; Gondim-Ribeiro
V A E β - T C V A
E
S ea t b e l t
[Figure]
To summarise: We provide insights into what makes VAEs vulnerable to attack and how we might go about defending them. We unearth novel connections between disentanglement and adversarial robustness.
We demonstrate that regularised VAEs, trained with an up-weighted total correlation, are much more robust to attacks than vanilla VAEs.
Building on this we develop regularised hierarchical VAEs that are more robustness still and offer improved reconstructions.
Finally, we show that robustness to adversarial attack also confers increased robustness to downstream tasks.
Updates of the paper: This article is an expanded version of that which appeared online in June 2019; it has been extended with experiments on downstream tasks and an extra, novel, attack mode.
B ACKGROUND : A TTACKING VAE S
In adversarial attacks an agent is trying to manipulate the behaviour of some model towards a goal of their choosing (Akhtar & Mian, 2018; Gilmer et al., 2018).
For many deep learning models, very small changes in the input can produce large changes in output.
Attacks on VAEs have been proposed where the adversary looks to apply small input distortions that produce reconstructions close to a target adversarial image (Tabacof et al., 2016; Gondim-Ribeiro et al., 2018; Kos et al., 2018).
An example of this is shown in Fig 1, where a standard VAE is successfully attacked to turn Hugh Jackman into Anna Wintour.
Unlike more established adversarial settings, only a small number of such VAE attacks have been suggested in the literature.
The current known most effective mode of attack is a latent space attack (Tabacof et al., 2016; Gondim-Ribeiro et al., 2018; Kos et al., 2018).
This aims to ﬁnd a distorted image x ∗ = x + d such that its posterior q φ ( z | x ∗ ) is close to that of the agent’s chosen target image q φ ( z | x t ) under some metric.
This then implies that the likelihood p θ ( x t | z ) is high when given draws from the posterior of the adversarial example.
It is particularly important to be robust to this attack if one is concerned with using the encoder network of a VAE as part of a downstream task.
For a VAE with a single stochastic layer, the latent-space adversarial objective is
[Equation]
1) where r ( · , · ) is some divergence or distance, commonly a D KL (Tabacof et al., 2016; Gondim-Ribeiro et al., 2018).
We are penalising the L 2 norm of d too, so as to aim for attacks that change the image less.
We can then simply optimise to ﬁnd a good distortion d .
Alternatively, we can aim to directly increase the ELBO for the target datapoint (Kos et al., 2018):
[Equation]
D EFENDING VAE S
Given these approaches to attacking VAEs, the critical question is now how to defend them.
This problem was not considered by prior works.
To address it, we ﬁrst need to consider what makes VAEs vulnerable to adversarial attacks.
We argue that two key factors dictate whether we can perform a successful attack on a VAE: a) whether we can induce signiﬁcant changes in the encoding distribution q φ ( z | x ) through only small changes in the data x , and b) whether we can induce signiﬁcant changes in the reconstructed images through only small changes to the latents z .
The ﬁrst of these relates to the smoothness of the encoder mapping, the latter to the smoothness of the decoder mapping.
Consider, for the sake of argument, the case where the encoder–decoder process is almost completely noiseless.
Here successful reconstruction places no direct pressure for similar encodings to correspond to similar images: given sufﬁciently powerful networks, very small changes to embeddings z can imply very large changes to the reconstructed image; there is no ambiguity in the “correct” encoding of a particular datapoint.
In essence, we can have lookup–table style behaviour – nearby realisations of z do not necessarily relate to each other and very different images can have very similar encodings.
This will now be very vulnerable to adversarial attacks: small input changes can lead to large changes in the encoding, and small encoding changes can lead to large changes in the reconstruction.
It will also tend to overﬁt and have gaps in the aggregate posterior, q φ ( z )
= 1 N (cid:80) Nn =1 q φ ( z | x n ) , as each q φ ( z | x n ) will be sharply peaked.
These gaps can then be exploited by an adversary.
There are two mechanisms by which we can reduce this lookup-table behaviour, thereby reducing gaps in the aggregate posterior.
First, we can try to regulate the level of noise in the per-datapoint posterior covariance, to then obtain smoothness in the overall embeddings.
Having a stochastic encoding creates uncertainty in the latent that gives rise to a particular image, forcing similar latents to correspond to similar images.
Adding noise forces the VAE to smooth the encode-decode process in that similar images will lead to similar embeddings in the latent space, ensuring that small changes in the input result in small changes in the latent space and result in small changes in the decoded outputs.
This proportional input-output change is what we refer to as a ‘simple’ encode-decode process, which is the second mechanism that can reduce look-up table behaviour.
The fact that the VAE is vulnerable to adversarial attack suggests that its standard setup does not obtain sufﬁciently smooth and simple representations to provide an adequate defence.
Introducing additional regularisation to enforce simplicity or increased posterior covariance thus provides a prospect for defending VAEs.
We could attempt to obtain this by direct regularisation of the networks (e.g. weight decay).
Here, however, we focus on macro-level regularisation approaches as discussed in the next section.
The reason for this is that controlling the macroscopic behaviour of the networks through low-level regularisations can be difﬁcult to control and, in particular, difﬁcult to calibrate.
Further, as the most effective attack on VAEs currently attack the latent space, it is reasonable that regularisation methods that directly act on the properties of the latent space form a good place to start.
3. D ISENTANGLING M ETHODS AND R OBUSTNESS
Recent research into disentangling VAEs (Higgins et al., 2017a; Siddharth et al., 2017; Kim &
Mnih, 2018; Chen et al., 2018; Esmaeili et al., 2019; Mathieu et al., 2019) and the information bottleneck (Alemi et al., 2017; 2018) has looked to regularise the ELBO with the hope of providing more interpretable embeddings.
These regularisers also have inﬂuences on the smoothness and stochasticity of the embeddings learned.
Of particular relevance, Mathieu et al.
(2019) introduce the notion of overlap in the embedding of a VAE: the level of overlap between per-datapoint posteriors as they combine to form the aggregate posterior.
Controlling this is critical to achieving a smoothly varying latent embedding.
Overlap encapsulates both the level of uncertainty in the encoding process and also a locality of this uncertainty.
To learn a smooth representation we not only need our encoder distribution to have an appropriate entropy, we also want the different possible encodings to be similar to each other.
Critically, Mathieu et al.
(2019) show that many methods proposed for disentangling, and in particular the β -VAE (Higgins et al., 2017a; Alemi et al., 2017), provide a mechanism for directly controlling this overlap.
Going back to our previous arguments, we see that controlling this overlap may also provide a mechanism for improving VAEs’ robustness.
This observation now hints at an interesting question: can we use methods initially proposed to encourage disentanglement to encourage robustness ?
It is important to note here that disentangling can be difﬁcult to achieve in practice, typically requiring precise choices in the hyperparameters of the model and the weighting of the added regularisation term, and often also a fair degree of luck (Locatello et al., 2019; Mathieu et al., 2019; Rolinek et al., 2019).
As such, we are not suggesting to induce disentangled representations to induces robustness, or indeed that disentangled representations should be any more robust.
Rather, as highlighted above, we are interested in whether the regularisers traditionally used to encourage disentanglement reliably lead to adversarially robust VAEs.
Indeed, we will ﬁnd that though our approaches—based on these regularisers—provide reliable and signiﬁcant improvements in robustness, these improvements are not generally due to any noticeable improvements in disentanglement itself (see Appendix E.1).
Regularising for Robustness There are a number of different disentanglement methods that one might consider using to train robust VAEs.
Perhaps the simplest would be to use a β -VAE (Higgins et al., 2017a), wherein we up-weight the D KL term in the VAE’s ELBO by a factor β ≥ 1 .
However, as mentioned previously the β -VAE only increases overlap at the expense of substantial reductions in reconstruction quality as the data likelihood term has, in effect, been down-weighted (Kim & Mnih, 2018; Chen et al., 2018; Mathieu et al., 2019).
Because of these shortfalls, we instead propose to regularise through penalisation of a total correlation (TC) term (Kim & Mnih, 2018; Chen et al., 2018).
As discussed in Section A.1, this looks to directly force independence across the different latent dimensions in aggregate posterior q φ ( z ) , such that the aggregate posterior factorises across dimensions.
This approach has been shown to have a smaller deleterious effect on reconstruction quality than found in β -VAEs
(Chen et al., 2018).
As seen in
Fig 2 this method also gives greater overlap by increasing posterior variance.
To summarise, the greater overlap and the lesser degradation of reconstruction quality induced by β -TCVAE make them highly suitable for our purposes.
3. A DVERSARIAL A TTACKS ON TC-P ENALISED VAE S
We now consider attacking these TC-penalised VAEs and demonstrate one of the key contributions of the paper: that empirically this form of regularisation makes adversarial attacks on VAEs harder to carry out.
To do this, we ﬁrst train them under the β -TCVAE objective (i.e. Eq (15)), jointly optimising θ, φ for a given β .
Once trained, we then attack the models using the latent-space attack method outlined in Section 2, ﬁnding an input distortion d that minimises the latent attack loss ∆ as per Eq (1) with r (
· , · ) =
D KL ( ·||· ) .
One possible metric for how successful such attacks have been is the achieved value reached of the attack loss ∆ KL .
If the latent space distributions for the original input and for the distorted input match closely for a small distortion, then ∆ KL is small and the model has been successfully fooled – reconstructions from samples from the attacked posterior would be indistinguishable from those from the target posterior.
Meanwhile, the larger the converged value of the attack loss the less similar these distributions are and the more different the reconstructed image is to the adversarial target image.
We carry our these attacks for dSprites (Matthey et al., 2017), Chairs (Aubry et al., 2014) and 3D faces (Paysan et al., 2009), for a range of β and λ values.
We pick values of λ following standard methodology (Tabacof et al., 2016; Gondim-Ribeiro et al., 2018), and use L-BFGS-B for gradient descent (Byrd et al., 1995).
We also varied the dimensionality of the latent space of the model, d z , but found it had little effect on the effectiveness of the attack.
In Fig 3 we show the effect on the attack loss ∆ KL for varying β , averaged over different original input-target pairs and values of d z .
Note that the plot is logarithmic in the loss.
We see a clear pattern for each dataset that the loss values reached by the adversary increases as we increase β from the standard VAE (i.e. β = 1 ).
This analysis is also borne out by visual inspection of the effectiveness of these attacks, for example as shown in Fig 1.
We will return to give further experimental results in
Section 5.
An interesting aspect of Fig 3 is that in many cases the adversarial loss starts to decrease if β is too large: as β increases there is less pressure in the objective to produce good reconstructions. A d v e r s a r i a l
Lo ss
Latent 1  81.
1e
Output
[Figure]
H IERARCHICAL T C –P ENALISED VAE S
We are now armed with the fact that penalising the TC in the ELBO induces robustness in VAEs.
However, TC-penalisation in single layer VAEs comes at the expense of model reconstruction quality (Chen et al., 2018), albeit less than that in β -VAEs.
Our aim is to develop a model that is robust to adversarial attack while mitigating this trade-off between robustness and sample quality.
To achieve this, we now consider instead using hierarchical VAEs (Rezende et al., 2014;
Sønderby et al., 2016;
Kingma et al., 2016;
Zhao et al., 2017; Maaløe et al., 2019; Vahdat & Kautz, 2020; Child, 2021).
These are known for their superior modelling capabilities and more accurate reconstructions.
As these gains stem from using more complex hierarchical latent spaces, rather than less noisy encoders, this suggests they may be able to produce better reconstructions and generative capabilities, while also remaining robust to adversarial attacks when appropriately regularised.
The simplest hierarchical extension of conditional stochastic variables in the generative model is the
Deep Latent Gaussian Model (DLGM) of Rezende et al.
Here the forward model factorises as a chain, p θ ( x ,(cid:126) z ) =
p θ ( x | z 1 ) (cid:81)
L − 1 i =1 p
θ ( z i |
z i +1 ) p ( z L ) , where each p θ ( z i
| z i +1 ) is a Gaussian distribution with mean and variance parameterised by deep nets, while p ( z L ) is an isotropic Gaussian.
Unfortunately, we found that naively applying TC-correlation penalisation to DLGM-style VAEs did not confer the improved robustness we observed in single layer VAEs.
We postulate that this observed weakness is inherent to the structure of chain factorisation in the generative model.
This means that the data-likelihood depends solely on z 1 , the bottom-most latent variable, and attackers only need to manipulate z 1 to produce a successful attack.
To account for this, we instead use a generative model in which the likelihood p θ ( x | (cid:126) z ) depends on all the latent variables in the chain (cid:126) z , rather than just the bottom layer z 1 , as has been done in Kingma et al.
; Maaløe et al.
This leads to the following factorisation of the generative structure:
[Equation]
To construct the ELBO, we must further introduce an inference network q φ ( (cid:126) z | x ) .
On the basis of simplicity and that it produces effective empirical performance, we use the factorisation:
[Equation]
where each conditional distribution q φ ( z i +1 |
z i , x ) takes the form of a Gaussian.
Again, marginalising out intermediate z i layers, q φ ( z L | x ) is a non-Gaussian, highly ﬂexible distribution.
To defend this model against adversarial attack, we apply TC regularisation term as per the last section.
We refer to the resulting models as Seatbelt-VAEs.
We obtain a decomposition of the ELBO for this model, revealing the existence of a TC term for the top-most layer (see Appendix B for proof).
Theorem 1.
The Evidence Lower Bound, for a hierarchical VAE with forward model as in Eq (3) and amortised variational posterior as in Eq (4) , can be decomposed to reveal the total correlation (see Deﬁnition A.1), of the aggregate posterior of the top-most layer of latent variables:
[Equation]
where the last term is the required TC term, and, using j to index over the coordinates in z L ,
[Equation]
In other words, following the Factor and β -TCVAEs, we up-weight the TC term for z L .
We can upweight this term then recombine the decomposed parts of the ELBO, to give us the following compact form of this objective.
Deﬁnition 1.
A Seatbelt-VAE is a hierarchical VAE with forward model as in Eq (3) and amortised variational posterior as in Eq (4) , trained wrt its parameters θ, φ to maximise the objective:
[Equation]
We see that, when L = 1 , a Seatbelt-VAE reduces to a β -TCVAE.
We use the β = 1 case as a baseline in our experiments as it corresponds to a Vanilla VAE for L = 1 and for L > 1 , β = 1 it produces a hierarchical model with a likelihood function conditioned on all latents.
As with the β -TCVAE, training L Seatbelt θ,φ ; β, D using stochastic gradient ascent with minibatches of the data is complicated by the presence of aggregate posteriors q φ ( z ) which depend on the entire dataset.
To deal with this, Appendix C we derive a minibatch estimator for TC-penalised hierarchical VAEs, building off that used for β -TCVAEs
(Chen et al., 2018).
We note that, as in Chen et al. (2018), large batch sizes are generally required to provide accurate TC estimates.
Attacking Hierarchical TC –Penalised VAEs In the above hierarchical model the likelihood over data is conditioned on all layers, so manipulations to any layer have the potential to be signiﬁcant.
We focus on simultaneously attacking all layers, noting that, as shown in Appendix D, this is more effective that just targeting the top or base layers individually.
Hence our adversarial objective for latent-space attacks on Seatbelt-VAEs is the following generalisation of that introduced in Tabacof et al.
; Gondim-Ribeiro et al.
; Kos et al.
(2018), to attack all the layers at the same time:
[Equation]
E XPERIMENTS
Expanding on the brief experiments in Section 3.2, we perform a battery of adversarial attacks on each of the introduced models.
We do this for three different adversarial attacks: ﬁrst (as in Section 3.2) a latent attack, Eqs (1,10) using the D KL divergence between attacked and target posteriors; secondly, we attack via the model’s output, aiming to make the target maximally likely under the attacked model as in Eq (2); ﬁnally, a new latent attack method as per Eqs (1,10) where we use r ( · , · ) =
W 2 ( · , · ) , the 2-Wasserstein distance between attacked and target posteriors.
We then evaluate the effectiveness of these attacks in three ways.
First, like Fig 1, we can plot the attacks themselves, to see how effective these attacks are in fooling us.
Secondly, we can measure the adversary’s loss under the attack objective.
Thirdly, we give the negative adversarial likelihood of the target image x t given an attacked latent representation z ∗ .
Larger, more positive, values of − log p θ ( x t | z ∗ ) correspond to less successful attacks as they correspond to large distances between the target and the adversarial reconstruction.
Lower values correspond to successful attacks as they correspond to a small distance between the adversarial target and the reconstruction.
We also measure
[Figure]
reconstruction quality of these models, as a function of degree of regularisation.
Finally, we also measure how downstream tasks that use output of these models perform under attack.
We train classiﬁers, on the reconstructions and on the latent representations, and see how robust performance is when the upstream VAE is attacked.
We demonstrate that hierarchical TC –Penalised VAEs (Seatbelt-VAEs) confer superior robustness to β -TCVAEs and standard VAEs, while preserving the ability to reconstruct inputs effectively.
Through this, we demonstrate that they are a powerful tool for learning robust deep generative models.
Following previous work (Tabacof et al., 2016; Gondim-Ribeiro et al., 2018) we randomly sample 10 input-target pairs for each dataset and for each image pair we consider 50 different values of λ geometrically-distributed from 2 − 20 to 2 20 .
Thus each individual trained model undergoesattacks for each attack mode.
As before, we used L-BFGS-B for gradient descent (Byrd et al., 1995).
We perform these experiments on Chairs (Aubry et al., 2014), 3D faces (Paysan et al., 2009), and
CelebA (Liu et al., 2015).
Details of neural architectures and training are given in Appendix G.
5. V ISUAL A PPRAISAL OF A TTACKS
We ﬁrst visually appraise the effectiveness of attacks that use the D KL divergence on vanilla VAEs, β -TCVAEs, and Seatbelt-VAEs.
As mentioned in Section 1, Fig 1 shows the results of latent space attacks on three models trained on CelebA. It is apparent that the β -TCVAE provides additional resilience to the attacks compared with the standard VAE.
Furthermore, this ﬁgure shows that SeatbeltVAEs are sufﬁciently robust to almost completely thwart the adversary: its adversarial construction still resembles the original input.
Moreover, this was achieved while also producing a clearer non– adversarial reconstruction.
One might expect attacks targeting a single generative factor underpinning the data to be easier.
However, we ﬁnd that these models protect effectively against this as well.
For example, see Fig 4 for plots showing an attacker attempting to rotate a dSprites heart.
In both ﬁgures we follow the method of Gondim-Ribeiro et al.
(2018) to plot attacks.
Those shown are representative of the adversarial inputs the attacker was able to ﬁnd over the 50 different values of λ .
The Seatbelt-VAE input only undergoes a small perturbation because it is sufﬁciently robust that the attacker is not able to make the reconstruction look more like the target image in any meaningful way, such that the optimiser never drifts far from the initial input.
Note that the β -TCVAE is also robust here.
The attacker is unable to induce the desired adversarial reconstruction, even though the attack may be of large magnitude.
In contrast, attacks on vanilla-VAEs are able to move through the latent space and ﬁnd a perturbation that reconstructs to the adversary’s target image.
5. Q UANTITATIVE A NALYSIS OF R OBUSTNESS
Having ascertained perceptually that Seatbelt-VAEs offer the strongest protection to adversarial attack, we now demonstrate this quantitatively.
Fig 5 shows − log p θ ( x t | z ∗ ) and ∆ over a range of datasets and β s for Seatbelt-VAEs ( L = 4 ) and β -TCVAEs for our three different attacks.
It demonstrates that the combination of depth and high TC-penalisation offers the best protection to
[Figure]
D K L
L a t e n t (
[Figure]
O u t pu t ( c )
W
L a t e n t
[Figure]
loss and negative adversarial likelihood. These results show that the hierarchical approach can offer very strong protection from the adversarial attacks studied.
In Appendix D we provide plots detailing these metrics for a range of L values.
In Appendix E we also calculate the L 2 distance between target images and adversarial outputs and show that the loss of effectiveness of adversarial attacks is not due to the degradation of reconstruction quality from increasing β .
We also test VAE robustness to random noise.
We noise the inputs and evaluate the model’s ability to reconstruct the original input.
Through this we are evaluating their ability to denoise.
See Appendix F for an illustration of this for TC-penalised models.
It is plausible that the ability of these models’ to denoise is linked to their robustness to attacks.
ELBO and Reconstructions Though Seatbelt-VAEs offer better protection to adversarial attack than β -TCVAEs, we also motivate their utility by way of their reconstruction quality.
In Fig 6 we plot the
ELBO of the two TC-penalised models, calculated without the β penalisation that was applied during training.
We further show the effect of depth and TC-penalisation on CelebA reconstructions.
These plots show that Seatbelt-VAEs’ reconstructions are more resilient to increasing β than β -TCVAEs’.
[Figure]
[Table]
5. P ROTECTION TO D OWNSTREAM T ASKS
Finally
[Table]
we consider the protection that Seatbelt-VAEs might provide to downstream tasks, noting that VAEs are often used as subcomponents in larger ML systems (Higgins et al., 2017b)
[Table]
or as a mechanism to protect another model from attack (Schott et al., 2019; Ghosh et al., 2019).
Tableshows results for classiﬁcation tasks using 2-layer MLPs and fully-convolutional nets trained on the reconstructions or on the embeddings.
It shows the drop in accuracy caused by an adversary that picks a target with a different label and attacks the VAEs’ embedding using the attack objective with λ = 1 .
We see that Seatbelt-VAEs produced signiﬁcantly better accuracies under these attacks.
C ONCLUSION
We have shown that VAEs can be rendered more robust to adversarial attacks by regularising the evidence lower bound.
This increase in robustness can be strengthened by extending these regularisation methods to hierarchical VAEs, forming Seatbelt-VAEs, which uses a generative structure where the likelihood makes use of all the latent variables.
Designing robust VAEs is becoming pressing as they are increasingly deployed as subcomponents in larger pipelines.
As we have shown, methods typically used for disentangling, motivated by their ability to provide interpretable representations, also confer robustness.
Studying the beneﬁcial effects of these methods is starting to come to the fore of VAE research. A CKNOWLEDGEMENTS
This research was directly funded by the Alan Turing Institute under Engineering and Physical
Sciences Research Council (EPSRC) grant EP/N510129/1.
MW was supported by EPSRC grant
EP/G03706X/1. AC was supported by an EPSRC Studentship. SR gratefully acknowledges support from the UK Royal Academy of Engineering and the Oxford-Man Institute. CH was supported by the
Medical Research Council, the Engineering and Physical Sciences Research Council, Health Data
Research UK, and the Li Ka Shing Foundation
We thank Tomas Lazauskas, Jim Madge and Oscar Giles from the Alan Turing Institute’s Research
Engineering team for their help and support.
Variational autoencoders (VAEs) are a variety of generative model suitable for high-dimensional data like images (Kingma & Welling, 2014; Rezende et al., 2014).
They introduce a joint distribution over data x
and latent variables z : p θ ( x , z ) =
p θ ( x | z ) p ( z ) , where p θ ( x | z ) is an appropriate distribution given the form of the data, the parameters of which are represented by deep nets with parameters θ , and p ( z ) =
N (0 , I ) is a common choice for the prior.
As exact inference is intractable, one performs amortised stochastic variational inference by introducing an inference network for the latent variables, q φ ( z | x ) , which often also takes the form of a Gaussian, N ( z | µ φ ( x ) , Σ φ ( x )) .
We can then perform gradient ascent, with respect to both θ and φ , on the evidence lower bound (ELBO)
[Equation]
(11) using the reparameterisation trick to take gradients through Monte Carlo samples from q φ ( z | x ) .
A. D ISENTANGLING VAE S
When learning disentangled representations (Bengio et al., 2013) in a VAE, one attempts to establish a one-to-one correspondence between dimensions of the learnt latent space and some interpretable aspect of the data (Higgins et al., 2017a; Burgess et al., 2017; Chen et al., 2018; Mathieu et al., 2019).
One dimension of the latent space could encode the rotation of a face for instance.
Mathieu et al.
(2019) offers a broader perspective, where disentangling can be interpreted as a particular case of decomposition .
In decomposition, models have the right degree of overlap between their latent posteriors such that the aggregate posterior matches the prior well throughout the latent space Z .
Disentangling is often enforced by an added penalisation to the VAE ELBO that acts akin to a regularisation method.
Because of this, disentangling can be difﬁcult to achieve in practice, and often requires precisely choosing the hyperparameters of the model and of the weighting of the added regularisation term (Locatello et al., 2019; Mathieu et al., 2019; Rolinek et al., 2019).
That disentangling relies on forms of soft supervision renders the task of learning disentangled representations potentially problematic (Khemakhem et al., 2020).
When viewed as a purely unsupervised task it can be hard to establish a direct correspondence between a disentangling-VAE’s training objective and the learning of a disentangled latent space.
Nevertheless, models trained under disentangling objectives have other beneﬁcial properties.
For example, the encoders of some disentangled VAEs have been used as the perceptual part of deep reinforcement learning models to create agents more robust to variation in their environment (Higgins et al., 2017b).
Thus, regardless of the presence of disentangled generative factors, these regularisation methods can be useful for downstream tasks.
In this paper we show that methods developed to obtain disentangled representations have the beneﬁt of conferring robustness to adversarial attack.
A commonly used disentangling method is that of the β -VAE.
In a β -VAE (Higgins et al., 2017a), a free parameter β multiplies the D KL term in the evidence lower bound L ( x ) .
This objective L β ( x ) remains a lower bound on the evidence:
[Equation]
The β -VAE though it offers a simple method for obtaining potentially disentangled representations does so at the expense of model quality.
Models trained with large β penalisation suffer from poor quality reconstructions and lower ELBO.
For more discussion of their theoretical aspects, see Kumar & Poole (2020).
Other methods seek to offset this degradation in model quality by decomposing the ELBO and more precisely targeting the regularisation when obtaining disentangled representations.
We can more insight into VAEs by deﬁning the evidence lower bound not per data-point, but instead over the dataset D of size N , D = { x n } , so we have L ( θ, φ, D ) (Hoffman & Johnson, 2016; Makhzani et al., 2016; Kim & Mnih, 2018;
Chen et al., 2018; Esmaeili et al., 2019).
From this, Esmaeili et al.
(2019) gives a decomposition of the dataset-level evidence lower bound:
[Equation]
where under the assumption that p ( z ) factorises we can further decompose 4 :
[Equation]
where j indexes over coordinates in z .
q φ ( z , x ) =
q φ ( z | x ) q ( x ) and q ( x ) :
= 1 N (cid:80) Nn =1 δ ( x − x n ) is the empirical data distribution.
q φ ( z ) :
= 1 N (cid:80) Nn =1 q φ ( z | x n ) is called the aggregate posterior.
A is the total correlation (TC) for q φ ( z ) .
Deﬁnition A.1.
The total correlation (TC) is a generalisation of mutual information to multiple variables (Watanabe, 1960) and is often used as the objective Independent Component Analysis (Bell & Sejnowski, 1995).
The TC is deﬁned as is deﬁned as the KL divergence from the joint distribution p ( s ) , s ∈ R d to the independent distribution over the dimensions of the variable s : p ( s 1 ) p ( s 2 ) . . .
p ( s n ) .
Formally: TC
[Equation]
With this mean-ﬁeld p ( z ) , Factor and β -TCVAEs upweight the TC of the aggregate posterior, so we have an objective:
[Equation]
Upweighting the penalisation associated with the TC term promotes the learning of independent latent factors, one of the key objectives of disentangling.
Chen et al.
(2018) show empirically that the learnt representations are disentangled when the hyperparameters of the model are well-chosen.
They also give a differentiable, stochastic approximation to E q φ ( z ) log q φ ( z ) , rendering this decomposition simple to use as a training objective using stochastic gradient descent.
However this is a biased estimator: it is a nested expectation, for which unbiased, ﬁnite–variance, estimators do not generally exist (Rainforth et al., 2018).
Consequently, it has the unfortunate consequence of needing large batch sizes to have the desired behaviour; for small batch sizes its practical behaviour mimics that of the β -VAE (Mathieu et al., 2019). A. β -VAE S , TC -P ENALISATION AND O VERLAP [Figure]
Recall from the discussion in § 3 that it is gaps, holes, in the aggregate posterior that adversaries can exploit.
We also want to close up these holes without degrading the model too much.
Rezende &
Viola (2018) observed that in regions of Z when the aggregate posterior places no density the decoder is unconstrained by the ELBO. It is these regions, with associated unconstrained decoder behaviour, that enable adversaries to have an easy time attacking the model. Thus our aim in making robust VAEs is to have an aggregate posterior that is smooth in the sense of having relatively ﬂat density across Z , so therefore having no holes.
This is equivalent to overlap, as introduced in Mathieu et al.
So, why do these regularisation methods increase overlap?
Why can upweighting penalisation of the
Total Correlation – demanding that the aggregate posterior is well-approximated by the product of its marginals – be expected to increase overlap?
And why it does so in a superior way to a β − VAE’s upweighting of D KL ( q φ ( z | x ) || p ( z )) ?
Recall that in Fig 2 we showed that the L 2 norm of the standard deviation of the encoder concentrates at a particular value for β -VAEs, but for β
-TCVAEs
it takes a broader ranger of values, values above the saturation point of β -VAEs.
In a β -VAE with large β we are asking that the amortised posterior is close to the prior for all inputs.
So for p ( z ) = N (0 , 1) we are forcing µ φ ( x ) to 0 and σ φ ( x ) to 1 .
Naturally this will lead our aggregate posterior to have a high degree of overlap between its constituent mixture components, because all of them are being driven to be the same.
And with all per-datapoint posteriors being driven to be the same, information about the initial input data is necessarily lost in these representations.
For a β -TCVAE, however, the demand for the aggregate posterior to be well-approximated by the product of its marginals does not in itself entail a ﬁxed scale, nor does it push all the per-datapoint posteriors towards the prior.
Rather we are directly asking for statistical independence between coordinate directions.
Holes in the aggregate posterior are (as long as they are off-axis) a form of dependency between the latent variables.
By demanding that the aggregate posterior factorises, we are thus asking the model to ’smooth out’ any holes (or peaks) that do not lie along the axes of the latent space.
Intuitively, and as shown in Figure 2, can be done achieved without causing as strong degradation to model quality, as measured by the ﬁdelity of reconstructions and the values of the ( β = 1 ) ELBO.
To give us a more direct understanding here we perform some toy experiments on ‘Swiss Roll’ data,
VAEs: vanilla, β -VAEs, and β -TCVAEs.
We plot the aggregate posterior and the reconstructions (the means of the likelihood conditioned on a sample of each per-datapoint posterior).
Clearly the amount of overlap increases with β for both kinds of model, but the β -TCVAEs seem to do this in a more structured way and, unlike the β -VAE, does not suffer from (eventually catastrophic) degradation in model quality for large β .
A. H IERARCHICAL VAE S
In a hierarchical VAE we have a set of L layers of z variables: (cid:126)
z = { z i } .
However, training DLGMs is challenging: the latent variables furthest from the data can fail to learn anything informative (Sønderby et al., 2016;
Zhao et al., 2017).
Due to the factorisation of q φ ( (cid:126) z | x ) and p θ ( x ,(cid:126) z ) in a
DLGM, it is possible for a single-layer VAE to train in isolation within a hierarchical model: each p θ ( z i |
z i +1 ) distribution can become a ﬁxed distribution not depending on z
i +1 such that each D KL divergence present in the objective between corresponding z i layers can still be driven to a local minima.
(Zhao et al., 2017) gives a proof of this separation for the case where the model is perfectly trained, i.e. D KL ( q φ ( z , x ) || p θ ( x , z ))
= 0 .
This is the hierarchical version of the collapse of z units in a single-layer VAE (Burda et al., 2016), but now the collapse is over entire layers z i .
It was part of the motivation for the Ladder VAE
(Sønderby et al., 2016) and BIVA (Maaløe et al., 2019).
More recently Vahdat & Kautz (2020); Child (2021) have shown that by judicious neural parameterisation and training strategy, hierarchical VAEs can obtain ∼ SOTA results in the probabilistic modelling and generation of images.
B T OTAL -C ORRELATION D ECOMPOSITION OF ELBO Proof of
Theorem
Here we prove that the ELBO for a hierarchical VAE with forward model as in Eq (3) and amortised variational posterior as in Eq (4) can be decomposed to reveal a total-correlation in the top-most latent variable.
Speciﬁcally, now considering the ELBO for the whole dataset and using q ( x ) to indicate the empirical data distribution
[Equation]
we will obtain, denoting z
= x :
[Equation]
We start with the forms of p and q given in Theorem 1.
The likelihood is conditioned on all z layers: p θ ( x | (cid:126) z ) .
[Equation]
So here we have three terms: an expectation over the data likelihood, the entropy of the empirical data distribution (a constant) and W .
We now can expand W to a term involving the prior for the latent z L and a term involving the conditional distributions from the generative model for the remaining components of (cid:126) z :
[Equation]
The ﬁrst part R , it that part of W not involving the prior for ‘top-most’ latent variable z L , is the ﬁrst subject of our attention.
We split out the part of R involving the generative and posterior terms for the latent variable closest to the data, z 1 and the rest: R =
[Equation]
The ﬁrst of these terms R a is an expectation over a D KL :
[Equation] [Equation]
And the rest, R b , provides the D KL divergences in the ELBO for all latent variables other than z L and z 1 .
It reduces to a sum of expectations over D KL divergences, one per latent variable.
[Equation]
Now we have:
[Equation]
We wish to apply TC decomposition to the top-most latent variable z L .
S is an expectation over the
D KL divergence between q φ ( z L | z L − 1 , x ) and p ( z L ) [Equation]
[Equation]
Applying the decomposition, with j indexes over units in z L .
[Equation]
Where we have used p ( z L ) =
(cid:81)
j p ( z Lj ) for our chosen generative model, a product of independent unit-variance Gaussian distributions.
[Equation]
Giving us a decomposition of the evidence lower bound that reveals the TC-term in z L , as required.
Multiplying this with a chosen pre-factor β gives us the required form.
C M INIBATCH W EIGHTED S AMPLING
As in Chen et al.
(2018), applying β -TC decomposition requires us to calculate terms of the form:
[Equation]
The i = 1 case is covered in the appendix of Chen et al.
First we will repeat the argument for i = 1 as made in Chen et al.
(2018), but in our notation,
and then we cover the case i > 1 for models with factorisation of q φ ( (cid:126)
z | x ) of Seatbelt VAEs.
C. MWS FOR β -TCVAE S
We denote B M = { x 1 , x 2 , ..., x M } , a minibatch of datapoints drawn uniformly iid from q ( x ) = 1 /N (cid:80)
Nn =1 δ ( x − x n ) .
For any minibatch we have p ( B M )
=
1 N M .
Chen et al.
(2018) introduce r ( B M | x ) , the probability of a sampled minibatch given that one member is x and the remaining
M − 1 points are sampled iid from q ( x ) , so r ( B M | x )
= 1 N M − 1 .
[Equation]
So then during training, one samples a minibatch { x 1 , x 2 , ..., x M } and can estimate
E q φ ( z 1 ) log q φ ( z 1 ) as:
[Equation]
and z 1 i is a sample from q φ ( z 1 | x i ) .
C. M INIBATCH W EIGHTED S AMPLING FOR S EATBELT -VAE S
Here we have that q ( (cid:126) z , x ) = (cid:81)
Ll =
[ q φ ( z l | z l − 1 , x ) ] q φ ( z 1 | x ) q ( x ) .
Now instead of having a minibatch of datapoints, we have a minibatch of draws of z i − 1 : B i − 1 M =
{ z i − 1 1 , z i − 1 2 , ..., z i − 1 M } .
Each member of which is the result of sequentially sampling along a chain, starting with some particular datapoint x m ∼ q ( x ) .
For i > 2 , members of B i − 1 M are drawn:
[Equation]
36) and for i = 2 :
[Equation] [Equation]
Thus each member of this batch B i − 1 M is the descendant of a particular datapoint that was sampled in an iid minibatch B M as deﬁned above.
We similarly deﬁne r ( B i − 1 M | z i − 1 , x ) as the probability of selecting a particular minibatch B i − 1 M of these values out from our set { ( x n , z i − 1 n ) } (of cardinality
N ) given that we have selected into our minibatch one particular pair of values ( x , z i − 1 ) from these
N values.
Like above, r ( B i − 1 M
[Equation]
Now we can consider E q φ ( z i ) log q φ ( z i ) for i > 1 :
[Equation]
Where we have followed the same steps as in the previous subsection.
During training, one samples a minibatch { z i − 1 1 , z i − 1 2 , ..., z i − 1 M } , where each is constructed by sampling ancestrally.
Then one can estimate E q φ ( z i ) log q φ ( z i ) as:
[Equation]
and z ik is a sample from q φ ( z i
| z i − 1 k , x k ) .
In our approach we only need terms of this form for i =
L , so we have:
[Equation]
and z Lk is a sample from q φ ( z L |
z L − 1 k , x k ) .
D S EATBELT -VAE R ESULTS D. S EATBELT -VAE LAYERWISE ATTACKS
L z
L z L
L z     7 × 10     7 × 10     7 × 10(a)
3D Faces 1
L z1 
 L z L 1
L z 0.
× 100. × 100.
× {+
 [Figure]+}
D. S EATBELT -VAE ATTACKS BY MODEL DEPTH AND β
L
Adversarial Likelihood 1.
5.6 × 10(a) − log p θ ( x t | z ∗ )
Faces
L
Adversarial Loss 1.
7.5 1e (b) ∆ Faces
L
Adversarial Likelihood 0.
× 10(c [Figure] [Figure] |
[Figure]
) Chairs
L
Adversarial Loss 0.
1e (d) ∆ Chairs
, ∆ grows by a factor of ≈ 10 7 and − log p θ ( x t | z ∗ ) doubles.
These results tell us that depth and TC-penalisation together, i.e Seatbelt-VAE, can offer immense protection from the adversarial attacks studied.
E A GGREGATE A NALYSIS OF A DVERSARIAL A TTACK
[Table]
[Figure]
[Table] [Figure] [Table] [Figure]
[Table] [Figure] [Table] [Table]
[Figure]
E. D ISENTANGLING AND R OBUSTNESS ?
Although we are using regularisation methods that were initially proposed to encourage disentangled representations, we are interested here in their effect on robustness not whether the representations we learn are in fact disentangled.
This is not least due to the questions that have arisen about the hyperparameter tuning required for disentangled representations Locatello et al.
; Rolinek et al.
For us the β pre-factor is just the degree of regularisation imposed.
However, it may be of interest to see what relationship, if any, exists between the ease of attacking of a model and how disentangled it is.
Here we show the MIG score (Chen et al., 2018) against the achieved adversarial loss on the Faces data for β -TCVAEs.
MIG measures the degree to which representations are disentangled and larger adversarial losses correspond to a less successful attack.
Shading is over the range of β and d z values.
There does not seem to be any simple correspondence between increased MIG and increases in adversarial loss, indicative of a less successful attack.
[Figure]
F R OBUSTNESS TO N OISE
[Figure]
4 in (b), taking β ∈ { 1 , 2 , 4 , 6 , 8 , 10 } .
Note the axis scalings are different for each subplot.
We see that for both models using β > 1 produces autoencoders that are better at denoising their inputs.
Namely, the mean of the density, i.e. E q φ ( z | x + (cid:15) )
[ log p θ ( x | z ) ], shifts dramatically to higher values for β >relative to β = 1 .
In other words, for both these models, the likelihood of the dataset in the noisy setting is much closer to the non-noisy dataset when β > 1 across all noise scales (0.1 (cid:15) , 0.5 (cid:15) , (cid:15) ).
G I MPLEMENTATION D ETAILS
All runs were done on the Azure cloud system on NC6 GPU machines.
G. E NCODER AND D ECODER A RCHITECTURES
We used the same convolutional network architectures as Chen et al.
For the encoders of all our models ( q ( ·| x ) )
we used purely convolutional networks with 5 convolutional layers.
When training on single-channel (binary/greyscale) datasets such as dSprites, 3D Faces, or Chairs the 5 layers took the following number of ﬁlters in order: { 32 , 32 , 64 , 64 , 512 } .
For more complex RGB datasets, such as CelebA, the layers had the following number of ﬁlters in order: { 64 , 64 , 128 , 128 , 512 } .
The mean and variance of the amortised posteriors are the output of dense layers acting on the output of the purely convolutional network, where the number of neurons in these layers is equal to the dimensionality of the latent space Z .
Similarly, for the decoders ( p ( x | z ) ) of all our models we also used purely convolutional networks with 6 deconvolutional layers.
When training on single-channel (binary/greyscale) datasets, dSprites, 3D Faces, or Chairs, the 6 layers took the following number of ﬁlters in order: { 512 , 64 , 64 , 32 , 32 , 1 } .
For CelebA the layers had the following number of ﬁlters in order: { 512 , 128 , 128 , 64 , 64 , 3 } .
The mean of the likelihood p ( x |· ) was directly encoded by the ﬁnal de-convolutional layer.
The variance of the decoder, σ , was ﬁxed to 0.1.
For β -TCVAE the range of d z values used was { 4 , 6 , 8 , 16 , 32 , 64 , 128 } .
For Seatbelt-VAEs the number of units in each layer z i decreases sequentially.
There is a list z sizes for each dataset, and for a model of L layers that the last L entries to give d z ,i , i ∈ { 1 , ..., L } .
[Equation]
[Equation]
For Seatbelt-VAEs we also have the mappings q φ ( z i +1 |
z i , x ) and p θ
( z i | z i +1 ) .
These are amortised as MLPs with 2 hidden layers with batchnorm and Leaky-ReLU activation.
The dimensionality of the hidden layers also decreases as a function of layer index i :
[Equation]
To train the model we used ADAM Kingma & Lei Ba (2015) with default parameters, a cosine decaying learning rate of 0.001, and a batch size of 1024.
All data was pre-processed to fall on the interval -1 to 1.
CelebA and Chairs were both downsampled and cropped as in Chen et al.
and
Kulkarni et al.
(2015) respectively.
We ﬁnd that using free-bits regularisation (Kingma et al., 2016) greatly ameliorates the optimisation challenges associated with DLGMs.