Compressed Sensing Using Generative Models
Compressed Sensing Using Generative Models
A generative model is given by a deterministic function We also take note of the related work of (Gilbert et al.,
G : Rk ! Rn , and a distribution PZ over z 2 Rk . To 2017) that connects model-based compressed sensing
generate a sample from the generator, we can draw z ⇠ PZ with the invertibility of Convolutional Neural Networks,
and the sample then is G(z). Typically, we have k ⌧ n, Bayesian compressed sensing (Ji et al., 2008) and compres-
i.e. the generative model maps from a low dimensional rep- sive sensing using Gaussian mixture models (Yang et al.,
resentation space to a high dimensional sample space. 2014).
Our approach is to find a vector in representation space A related result appears in (Baraniuk & Wakin, 2009),
such that the corresponding vector in the sample space which studies the measurement complexity of an RIP con-
matches the observed measurements. We thus define the dition for smooth manifolds. This is analogous to our
objective to be S-REC for the range of G, but the range of G is nei-
ther smooth (because of ReLUs) nor a manifold (because
loss(z) = kAG(z) yk2 (1) of self-intersection). Their recovery result was extended
By using any optimization procedure, we can minimize in (Hegde & Baraniuk, 2012) to unions of two manifolds.
loss(z) with respect to z. In particular, if the generative
model G is differentiable, we can evaluate the gradients 4. Theoretical Results
of the loss with respect to z using backpropagation and use
standard gradient based optimizers. If the optimization pro- We begin with a brief review of the Restricted Eigenvalue
cedure terminates at ẑ, our reconstruction for x⇤ is G(ẑ). Condition (REC) in standard compressed sensing. The
We define the measurement error to be kAG(ẑ) yk2 and REC is a sufficient condition on A for robust recovery to
the reconstruction error to be kG(ẑ) x⇤ k2 . be possible. The REC essentially requires that all “approx-
imately sparse” vectors are far from the nullspace of the
matrix A. More specifically, A satisfies REC for a constant
3. Related Work > 0 if for all approximately sparse vectors x,
Several recent lines of work explore generative models for kAxk kxk. (2)
reconstruction. The first line of work attempts to project
an image on to the representation space of the genera- It can be shown that this condition is sufficient for recovery
tor. These works assume full knowledge of the image, of sparse vectors using Lasso. If one examines the struc-
and are special cases of the linear measurements frame- ture of Lasso recovery proofs, a key property that is used is
work where the measurement matrix A is identity. Excel- that the difference of any two sparse vectors is also approx-
lent reconstruction results with SGD in the representation imately sparse (for sparsity up to 2k). This is a coincidence
space to find an image in the generator range have been that is particular to sparsity. By contrast, the difference of
reported by (Lipton & Tripathi, 2017) with stochastic clip- two vectors “natural” to our domain may not itself be natu-
ping and (Creswell & Bharath, 2016) with logistic mea- ral. The condition we need is that the difference of any two
surement loss. A different approach is introduced in (Du- natural vectors is far from the nullspace of A.
moulin et al., 2016) and (Donahue et al., 2016). In their
method, a recognition network that maps from the sam- We propose a generalized version of the REC for a set
ple space vector x to the representation space vector z is S ✓ Rn of vectors, the Set-Restricted Eigenvalue Con-
learned jointly with the generator in an adversarial setting. dition (S-REC):
Definition 1. Let S ✓ Rn . For some parameters >
A second line of work explores reconstruction with struc-
0, 0, a matrix A 2 Rm⇥n is said to satisfy the
tured partial observations. The inpainting problem consists
S-REC(S, , ) if 8 x1 , x2 2 S,
of predicting the values of missing pixels given a part of
the image. This is a special case of linear measurements kA(x1 x2 )k kx1 x2 k .
where each measurement corresponds to an observed pixel.
The use of generative models for this task has been stud-
There are two main differences between the S-REC and the
ied in (Yeh et al., 2016), where the objective is taken to be
standard REC in compressed sensing. First, the condition
a sum of L1 error in measurements and a perceptual loss
applies to differences of vectors in an arbitrary set S of
term given by the discriminator. Super-resolution is a re-
“natural” vectors, rather than just the set of approximately
lated task that attempts to increase the resolution of an im-
k-sparse vectors in some basis. This will let us apply the
age. We can view the observations as local spatial averages
definition to S being the range of a generative model.
of the unknown higher resolution image and hence cast this
as another special case of linear measurements. For prior Second, we allow an additive slack term . This is neces-
work on super-resolution see e.g. (Yang et al., 2010; Dong sary for us to achieve the S-REC when S is the output of
et al., 2016; Kim et al., 2016) and references therein. general Lipschitz functions. Without it, the S-REC depends
Compressed Sensing using Generative Models
on the behavior of S at arbitrarily small scales. Since there piecewise linear with at most two pieces. The popular
are arbitrarily many such local regions, one cannot guar- ReLU or LeakyReLU non-linearities satisfy this assump-
antee the existence of an A that works for all these local tion. We do not make any other assumption, and in par-
regions. Fortunately, as we shall see, poor behavior at a ticular, the magnitude of the weights in the network do not
small scale will only increase our error by O( ). affect our guarantee.
The S-REC definition requires that for any two vectors in Lemma 4.2. Let G : Rk ! Rn be a d-layer neural net-
S, if they are significantly different (so the right hand side work, where each layer is a linear transformation followed
is large), then the corresponding measurements should also by a pointwise non-linearity. Suppose there are at most c
be significantly different (left hand side). Hence we can nodes per layer, and the non-linearities are piecewise lin-
hope to approximate the unknown vector from the mea- ear with at most two pieces, and let
surements, if the measurement matrix satisfies the S-REC. ✓ ◆
1
m=⌦ kd log c
But how can we find such a matrix? To answer this, we ↵2
present two lemmas showing that random Gaussian matri-
for some ↵ < 1. Then a random matrix A 2
ces of relatively few measurements m satisfy the S-REC for
Rm⇥n with IID entries Aij ⇠ N (0, m1
) satisfies the
the outputs of large and practically useful classes of gener- ⌦(↵2 m)
ative models G : Rk ! Rn . S-REC(G(R ), 1 ↵, 0) with 1 e
k
probability.
In the first lemma, we assume that the generative model To show Theorems 1.1 and 1.2, we just need to show that
G(·) is L-Lipschitz, i.e., 8 z1 , z2 2 Rk , we have the S-REC implies good recovery. In order to make our
error guarantee relative to `2 error in the image space Rn ,
kG(z1 ) G(z2 )k Lkz1 z2 k. rather than in the measurement space Rm , we also need
that A preserves norms with high probability (Cohen et al.,
Note that state of the art neural network architectures
2009). Fortunately, Gaussian matrices (or other distribu-
with linear layers, (transposed) convolutions, max-pooling,
tional JL matrices) satisfy this property.
residual connections, and all popular non-linearities satisfy
this assumption. In Lemma 8.5 in the Appendix we give a Lemma 4.3. Let A 2 Rm⇥n by drawn from a distribution
simple bound on L in terms of parameters of the network; that (1) satisfies the S-REC(S, , ) with probability 1 p
for typical networks this is nO(d) . We also require the input and (2) has for every fixed x 2 Rn , kAxk 2kxk with
z to the generator to have bounded norm. Since generative probability 1 p.
models such as VAEs and GANs typically assume their in- For any x⇤ 2 Rn and noise ⌘, let y = Ax⇤ + ⌘. Let x
b
put z is drawn with independent uniform or Gaussian in- approximately minimize ky Axk over x 2 S, i.e.,
puts, this only prunes an exponentially unlikely fraction of
the possible outputs. ky xk min ky
Ab Axk + ✏.
x2S
Lemma 4.1. Let G : R ! R be L-Lipschitz. Let
k n
Then,
k k
B (r) = {z | z 2 R , kzk r} ✓ ◆
4 1
kb
x x⇤ k + 1 min kx⇤ xk + (2k⌘k + ✏ + )
be an L2 -norm ball in R . For ↵ < 1, if
k x2S
200
300
400
500
750
10
25
50
10000
1000
2500
5000
7500
100
200
500
20
50
1umEer Rf meaVurementV
1umber Rf meDsuremenWs
(a) Results on MNIST (b) Results on celebA
Figure 1. We compare the performance of our algorithm with baselines. We show a plot of per pixel reconstruction error as we vary the
number of measurements. The vertical bars indicate 95% confidence intervals.
optimization to explore more in the regions that are pre- 5.2. CelebA with DCGAN
ferred by the respective generative models (see compari-
CelebA is a dataset of more than 200, 000 face images
son to unregularized versions in Fig. 1). Thus the objective
of celebrities (Liu et al., 2015). The input images were
function we use for minimization is
cropped to a 64 ⇥ 64 RGB image, giving 64 ⇥ 64 ⇥ 3 =
kAG(z) yk2 + L(z). 12288 inputs per image. Each pixel value was scaled so
that all values are between [ 1, 1]. We trained a DCGAN
Both VAE and GAN typically imposes an isotropic Gaus- (Radford et al., 2015; Kim, 2017) on this dataset. We set
sian prior on z. Thus kzk2 is proportional to the negative the input dimension k = 100 and use a standard normal dis-
log-likelihood under this prior. Accordingly, we use the tribution. The architecture follows that of (Radford et al.,
following regularizer: 2015). The model was trained by one update to the discrim-
inator and two updates to the generator per cycle. Each up-
L(z) = kzk2 , (3) date used the Adam optimizer (Kingma & Ba, 2014) with
minibatch size 64, learning rate 0.0002 and 1 = 0.5. We
where measures the relative importance of the prior as use = 0.001 in Eqn. (3).
compared to the measurement error. For baselines, we perform sparse recovery using Lasso on
the images in two domains: (a) 2D Discrete Cosine Trans-
5.1. MNIST with VAE form (2D-DCT) and (b) 2D Daubechies-1 Wavelet Trans-
The MNIST dataset consists of about 60, 000 images of form (2D-DB1). While we provide Gaussian measure-
handwritten digits, where each image is of size 28⇥28 (Le- ments of the original pixel values, the L1 penalty is on ei-
Cun et al., 1998). Each pixel value is either 0 (background) ther the DCT coefficients or the DB1 coefficients of each
or 1 (foreground). No pre-processing was performed. We color channel of an image. For all experiments, we set the
trained VAE on this dataset. The input to the VAE is a vec- shrinkage parameter to be 0.1 and 0.00001 respectively for
torized binary image of input dimension 784. We set the 2D-DCT, and 2D-DB1.
size of the representation space k = 20. The recognition
network is a fully connected 784 500 500 20 network. 6. Experiments and Results
The generator is also fully connected with the architecture
20 500 500 784. We train the VAE using the Adam 6.1. Reconstruction from Gaussian measurements
optimizer (Kingma & Ba, 2014) with a mini-batch size 100 We take A to be a random matrix with IID Gaussian entries
and a learning rate of 0.001. We use = 0.1 in Eqn. (3). with zero mean and standard deviation of 1/m. Each entry
The digit images are reasonably sparse in the pixel space. of noise vector ⌘ is also an IID Gaussian random variable.
Thus, as a baseline, we use the pixel values directly for We compare performance of different sensing algorithms
sparse recovery using Lasso. We set shrinkage parameter qualitatively and quantitatively. For quantitative compari-
to be 0.1 for all the experiments. son, we use the reconstruction error = kx̂ x⇤ k2 , where x̂
Compressed Sensing using Generative Models
is an estimate of x⇤ returned by the algorithm. In all cases, measurement matrix may not satisfy the S-REC condition
we report the results on a held out test set, unseen by the (with good constants and ), and consequently, our theo-
generative model at training time. rems may not be applicable.
MNIST: The p standard deviation of the noise vector is MNIST: We construct a low resolution image by spatial
set such that E[k⌘k2 ] = 0.1. We use Adam opti- 2 ⇥ 2 pooling with a stride of 2 to produce a 14 ⇥ 14 image.
mizer (Kingma & Ba, 2014), with a learning rate of 0.01. These measurements are used to reconstruct the original
We do 10 random restarts with 1000 steps per restart and 28 ⇥ 28 image. Fig. 2b shows reconstructions produced
pick the reconstruction with best measurement error. by our algorithm on images from a held out test set. We
observe sharp reconstructions which closely match the fine
In Fig. 1a, we show the reconstruction error as we change
structure in the ground truth.
the number of measurements both for Lasso and our algo-
rithm. We observe that our algorithm is able to get low celebA: We construct a low resolution image by spatial 4⇥
errors with far fewer measurements. For example, our 4 pooling with a stride of 4 to produce a 16 ⇥ 16 image.
algorithm’s performance with 25 measurements matches These measurements are used to reconstruct the original
Lasso’s performance with 400 measurements. Fig. 2a 64 ⇥ 64 image. In Fig. 4 we show results on images from a
shows sample reconstructions by Lasso and our algorithm. held out test set. We see that our algorithm is able to fill in
the details to match the original image.
However, our algorithm is limited since its output is con-
strained to be in the range of the generator. After 100
measurements, our algorithm’s performance saturates, and 6.3. Understanding sources of error
additional measurements give no additional performance. Although better than baselines, our method still admits
Since Lasso has no such limitation, it eventually surpasses some error. This error can be decomposed into three com-
our algorithm, but this takes more than 500 measurements ponents: (a) Representation error: the unknown image is
of the 784-dimensional vector. We expect that a more far from the range of the generator (b) Measurement error:
powerful generative model with representation dimension The finite set of random measurements do not contain all
k > 20 can make better use of additional measurements. the information about the unknown image (c) Optimization
celebA: The p standard deviation of the noise vector is error: The optimization procedure did not find the best z.
set such that E[k⌘k2 ] = 0.01. We use Adam opti- In this section we present some experiments that suggest
mizer (Kingma & Ba, 2014), with a learning rate of 0.1. that the representation error is the dominant term. In our
We do 2 random restarts with 500 update steps per restart first experiment, we ensure that the representation error is
and pick the reconstruction with best measurement error. zero, and try to minimize the sum of other two errors. In
In Fig. 1b, we show the reconstruction error as we change this setting, we observe that the reconstructions are almost
the number of measurements both for Lasso and our algo- perfect. In the second experiment, we ensure that the mea-
rithm. In Fig. 3 we show sample reconstructions by Lasso surement error is zero, and try to minimize the sum of other
and our algorithm. We observe that our algorithm is able two. Here, we observe that the total error obtained is very
to produce reasonable reconstructions with as few as 500 close to the total error in our reconstruction experiments
measurements, while the output of the baseline algorithms (Sec. 6.1).
is quite blurry. Similar to the results on MNIST, if we con-
tinue to give more measurements, our algorithm saturates, 6.3.1. S ENSING IMAGES FROM RANGE OF GENERATOR
and for more than 5000 measurements, Lasso gets a better Our first approach is to sense an image that is in the range
reconstruction. We again expect that a more powerful gen- of the generator. More concretely, we sample a z ⇤ from
erative model with k > 100 would perform better in the PZ . Then we pass it through the generator to get x⇤ =
high-measurement regime. G(z ⇤ ). Now, we pretend that this is a real image and try to
sense that. This method eliminates the representation error
6.2. Super-resolution and allows us to check if our gradient based optimization
procedure is able to find z ⇤ by minimizing the objective.
Super-resolution is the task of constructing a high resolu-
tion image from a low resolution version of the same im- In Fig. 6a and Fig. 6b, we show the reconstruction error for
age. This problem can be thought of as special case of images in the range of the generators trained on MNIST
our general framework of linear measurements, where the and celebA datasets respectively. We see that we get almost
measurements correspond to local spatial averages of the perfect reconstruction with very few measurements. This
pixel values. Thus, we try to use our recovery algorithm suggests that objective is being properly minimized and we
to perform this task with measurement matrix A tailored indeed get ẑ close to z ⇤ . i.e. the sum of optimization error
to give only the relevant observations. We note that this and the measurement error is small in the absence of the
Compressed Sensing using Generative Models
(a) We show original images (top row) and reconstructions by (b) We show original images (top row), low resolution version
Lasso (middle row) and our algorithm (bottom row). of original images (middle row) and reconstructions (last row).
Figure 2. Results on MNIST. Reconstruction with 100 measurements (left) and Super-resolution (right)
OrLgLnDO
LDsso (DCT)
LDsso (WDveOeW)
DCGAN
Figure 3. Reconstruction results on celebA with m = 500 measurements (of n = 12288 dimensional vector). We show original images
(top row), and reconstructions by Lasso with DCT basis (second row), Lasso with wavelet basis (third row), and our algorithm (last row).
OriginDO
BOurreG
DCGAN
Figure 4. Super-resolution results on celebA. Top row has the original images. Second row shows the low resolution (4x smaller) version
of the original image. Last row shows the images produced by our algorithm.
OriginDO
DCGAN
Figure 5. Results on the representation error experiments on celebA. Top row shows original images and the bottom row shows closest
images found in the range of the generator.
Compressed Sensing using Generative Models
5eFRnstruFtiRn errRr (per pixel)
0.04
0.10
0.03
0.02
0.05
0.01
0.00 0.00
100
200
300
400
500
750
10
25
50
1000
2500
100
200
500
20
50
1umber Rf measurements
1umber Rf measurements
(a) Results on MNIST (b) Results on celebA
Figure 6. Reconstruction error for images in the range of the generator. The vertical bars indicate 95% confidence intervals.
Ji, Shihao, Xue, Ya, and Carin, Lawrence. Bayesian com- Tibshirani, Robert. Regression shrinkage and selection via
pressive sensing. IEEE Transactions on Signal Process- the lasso. Journal of the Royal Statistical Society. Series
ing, 56(6):2346–2356, 2008. B (Methodological), pp. 267–288, 1996.
Kim, Jiwon, Kwon Lee, Jung, and Mu Lee, Kyoung. Ac- Vershynin, Roman. Introduction to the non-asymptotic
curate image super-resolution using very deep convolu- analysis of random matrices. arXiv preprint
tional networks. In Proceedings of the IEEE Conference arXiv:1011.3027, 2010.
on Computer Vision and Pattern Recognition, pp. 1646–
1654, 2016. Yang, Jianbo, Yuan, Xin, Liao, Xuejun, Llull, Patrick,
Brady, David J, Sapiro, Guillermo, and Carin, Lawrence.
Kim, Taehoon. A tensorflow implementation of “deep Video compressive sensing using gaussian mixture mod-
convolutional generative adversarial networks”. els. IEEE Transactions on Image Processing, 23(11):
[Link] 4863–4878, 2014.
2017.
Yang, Jianchao, Wright, John, Huang, Thomas S, and Ma,
Kingma, Diederik and Ba, Jimmy. Adam: A Yi. Image super-resolution via sparse representation.
method for stochastic optimization. arXiv preprint IEEE transactions on image processing, 19(11):2861–
arXiv:1412.6980, 2014. 2873, 2010.
Kingma, Diederik P and Welling, Max. Auto-encoding
Yeh, Raymond, Chen, Chen, Lim, Teck Yian, Hasegawa-
variational bayes. arXiv preprint arXiv:1312.6114,
Johnson, Mark, and Do, Minh N. Semantic image in-
2013.
painting with perceptual and contextual losses. arXiv
LeCun, Yann, Bottou, Léon, Bengio, Yoshua, and Haffner, preprint arXiv:1607.07539, 2016.
Patrick. Gradient-based learning applied to document
recognition. Proceedings of the IEEE, 86(11):2278–
2324, 1998.
Lipton, Zachary C and Tripathi, Subarna. Precise recovery
of latent vectors from generative adversarial networks.
arXiv preprint arXiv:1702.04782, 2017.
Liu, Ziwei, Luo, Ping, Wang, Xiaogang, and Tang, Xiaoou.
Deep learning face attributes in the wild. In Proceedings
of the IEEE International Conference on Computer Vi-
sion, pp. 3730–3738, 2015.
Loh, Po-Ling and Wainwright, Martin J. High-dimensional
regression with noisy and missing data: Provable guar-
antees with non-convexity. In Advances in Neural Infor-
mation Processing Systems, pp. 2726–2734, 2011.
Lustig, Michael, Donoho, David, and Pauly, John M.
Sparse mri: The application of compressed sensing for
rapid mr imaging. Magnetic resonance in medicine, 58
(6):1182–1195, 2007.
Matoušek, Jiřı́. Lectures on discrete geometry, volume 212.
Springer Science & Business Media, 2002.
Negahban, Sahand, Yu, Bin, Wainwright, Martin J, and
Ravikumar, Pradeep K. A unified framework for high-
dimensional analysis of m-estimators with decompos-
able regularizers. In Advances in Neural Information
Processing Systems, pp. 1348–1356, 2009.
Radford, Alec, Metz, Luke, and Chintala, Soumith. Un-
supervised representation learning with deep convolu-
tional generative adversarial networks. arXiv preprint
arXiv:1511.06434, 2015.