REF-21-MemNet - A Persistent Memory Network For Image Restoration
REF-21-MemNet - A Persistent Memory Network For Image Restoration
Abstract
(a) Plain structure
Recently, very deep convolutional neural networks
(CNNs) have been attracting considerable attention in im-
age restoration. However, as the depth grows, the long-term (b) Skip connections
dependency problem is rarely realized for these very deep
models, which results in the prior states/layers having lit-
tle influence on the subsequent ones. Motivated by the fact Gate Unit
that human thoughts have persistency, we propose a very Recursive Unit
deep persistent memory network (MemNet) that introduces
a memory block, consisting of a recursive unit and a gate (c) Proposed memory block
unit, to explicitly mine persistent memory through an adap-
Figure 1. Prior network structures (a,b) and our memory block (c).
tive learning process. The recursive unit learns multi-level The blue circles denote a recursive unit with an unfolded structure
representations of the current state under different recep- which generates the short-term memory. The green arrow denotes
tive fields. The representations and the outputs from the the long-term memory from the previous memory blocks that is
previous memory blocks are concatenated and sent to the directly passed to the gate unit.
gate unit, which adaptively controls how much of the pre-
vious states should be reserved, and decides how much of the additive noise. With this mathematical model, extensive
the current state should be stored. We apply MemNet to studies are conducted on many image restoration tasks, e.g.,
three image restoration tasks, i.e., image denosing, super- image denoising [2, 5, 9, 37], single-image super-resolution
resolution and JPEG deblocking. Comprehensive exper- (SISR) [15, 38] and JPEG deblocking [18, 26].
iments demonstrate the necessity of the MemNet and its As three classical image restoration tasks, image de-
unanimous superiority on all three tasks over the state of noising aims to recover a clean image from a noisy ob-
the arts. Code is available at https://github.com/ servation, which commonly assumes additive white Gaus-
tyshiwo/MemNet. sian noise with a standard deviation σ; single-image super-
resolution recovers a high-resolution (HR) image from a
low-resolution (LR) image; and JPEG deblocking removes
1. Introduction the blocking artifact caused by JPEG compression [7].
Image restoration [29] is a classical problem in low-level Recently, due to the powerful learning ability, very deep
computer vision, which estimates an uncorrupted image convolutional neural network (CNN) is widely used to
from a noisy or blurry one. A corrupted low-quality image tackle the image restoration tasks. Kim et al. construct a
x can be represented as: x = D(x̃) + n, where x̃ is a high- 20-layer CNN structure named VDSR for SISR [20], and
quality version of x, D is the degradation function and n is adopts residual learning to ease training difficulty. To con-
trol the parameter number of very deep models, the authors
∗ This work was supported by the National Science Fund of China un-
further introduce a recursive layer and propose a Deeply-
der Grant Nos. 91420201, 61472187, 61502235, 61233011, 61373063
and 61602244, the 973 Program No. 2014CB349303, Program for
Recursive Convolutional Network (DRCN) [21]. To mite-
Changjiang Scholars, and partially sponsored by CCF-Tencent Open Re- gate training difficulty, Mao et al. [27] introduce symmetric
search Fund. Jian Yang and Xiaoming Liu are corresponding authors. skip connections into a 30-layer convolutional auto-encoder
network named RED for image denoising and SISR. More- connected structure helps compensate mid/high-frequency
over, Zhang et al. [40] propose a denoising convolutional signals, and ensures maximum information flow between
neural network (DnCNN) to tackle image denoising, SISR memory blocks as well. To the best of our knowledge, it is
and JPEG deblocking simultaneously. by far the deepest network for image restoration.
The conventional plain CNNs, e.g., VDSR [20], The same MemNet structure achieves the state-of-the-
DRCN [21] and DnCNN [40] (Fig. 1(a)), adopt the single- art performance in image denoising, super-resolution and
path feed-forward architecture, where one state is mainly in- JPEG deblocking. Due to the strong learning ability, our
fluenced by its direct former state, namely short-term mem- MemNet can be trained to handle different levels of corrup-
ory. Some variants of CNNs, RED [27] and ResNet [12] tion even using a single model.
(Fig. 1(b)), have skip connections to pass information
across several layers. In these networks, apart from the 2. Related Work
short-term memory, one state is also influenced by a spe-
The success of AlexNet [22] in ImageNet [31] starts the
cific prior state, namely restricted long-term memory. In
era of deep learning for vision, and the popular networks,
essence, recent evidence suggests that mammalian brain
GoogleNet [33], Highway network [32], ResNet [12], re-
may protect previously-acquired knowledge in neocortical
veal that the network depth is of crucial importance.
circuits [4]. However, none of above CNN models has such
As the early attempt, Jain et al. [17] proposed a simple
mechanism to achieve persistent memory. As the depth
CNN to recover a clean natural image from a noisy observa-
grows, they face the issue of lacking long-term memory.
tion and achieved comparable performance with the wavelet
To address this issue, we propose a very deep persis-
methods. As the pioneer CNN model for SISR, super-
tent memory network (MemNet), which introduces a mem-
resolution convolutional neural network (SRCNN) [8] pre-
ory block to explicitly mine persistent memory through an
dicts the nonlinear LR-HR mapping via a fully deep con-
adaptive learning process. In MemNet, a Feature Extrac-
volutional network, which significantly outperforms classi-
tion Net (FENet) first extracts features from the low-quality
cal shallow methods. The authors further proposed an ex-
image. Then, several memory blocks are stacked with a
tended CNN model, named Artifacts Reduction Convolu-
densely connected structure to solve the image restoration
tional Neural Networks (ARCNN) [7], to effectively handle
task. Finally, a Reconstruction Net (ReconNet) is adopted
JPEG compression artifacts.
to learn the residual, rather than the direct mapping, to ease
To incorporate task-specific priors, Wang et al. adopted
the training difficulty.
a cascaded sparse coding network to fully exploit the nat-
As the key component of MemNet, a memory block con-
ural sparsity of images [36]. In [35], a deep dual-domain
tains a recursive unit and a gate unit. Inspired by neuro-
approach is proposed to combine both the prior knowl-
science [6, 25] that recursive connections ubiquitously ex-
edge in the JPEG compression scheme and the practice of
ist in the neocortex, the recursive unit learns multi-level
dual-domain sparse coding. Guo et al. [10] also proposed
representations of the current state under different recep-
a dual-domain convolutional network that jointly learns a
tive fields (blue circles in Fig. 1(c)), which can be seen as
very deep network in both DCT and pixel domains.
the short-term memory. The short-term memory generated
Recently, very deep CNNs become popular for image
from the recursive unit, and the long-term memory gener-
restoration. Kim et al. [20] stacked 20 convolutional lay-
ated from the previous memory blocks 1 (green arrow in
ers to exploit large contextual information. Residual learn-
Fig. 1(c)) are concatenated and sent to the gate unit, which
ing and adjustable gradient clipping are used to speed up
is a non-linear function to maintain persistent memory. Fur-
the training. Zhang et al. [40] introduced batch normal-
ther, we present an extended multi-supervised MemNet,
ization into a DnCNN model to jointly handle several im-
which fuses all intermediate predictions of memory blocks
age restoration tasks. To reduce the model complexity, the
to boost the performance.
DRCN model introduced recursive-supervision and skip-
In summary, the main contributions of this work include:
connection to mitigate the training difficulty [21]. Using
A memory block to accomplish the gating mechanism
symmetric skip connections, Mao et al. [27] proposed a
to help bridge the long-term dependencies. In each memory
very deep convolutional auto-encoder network for image
block, the gate unit adaptively learns different weights for
denoising and SISR. Very Recently, Lai et al. [23] pro-
different memories, which controls how much of the long-
posed LapSRN to address the problems of speed and ac-
term memory should be reserved, and decides how much of
curacy for SISR, which operates on LR images directly and
the short-term memory should be stored.
progressively reconstruct the sub-band residuals of HR im-
A very deep end-to-end persistent memory network (80
ages. Tai et al. [34] proposed deep recursive residual net-
convolutional layers) for image restoration. The densely
work (DRRN) to address the problems of model parameters
1 For the first memory block, its long-term memory comes from the and accuracy, which recursively learns the residual unit in a
output of FENet. multi-path model.
B0 B1 Bm BM
FENet Memory block 1 ... Memory block m ... Memory block M ReconNet
fext frec
x y
Figure 2. Basic MemNet architecture. The red dashed box represents multiple stacked memory blocks.
3. MemNet for Image Restoration we use a residual building block, which is introduced in
3.1. Basic Network Architecture ResNet [12] and shows powerful learning ability for object
Our MemNet consists of three parts: a feature extraction recognition, as a recursion in the recursive unit. A residual
net FENet, multiple stacked memory blocks and finally a building block in the m-th memory block is formulated as,
reconstruction net ReconNet (Fig. 2). Let’s denote x and y r
Hm r−1
= Rm (Hm r−1
) = F(Hm r−1
, Wm ) + Hm , (5)
as the input and output of MemNet. Specifically, a convo-
lutional layer is used in FENet to extract the features from r−1 r
where Hm , Hm are the input and output of the r-th resid-
the noisy or blurry input image, 0
ual building block respectively. When r = 1, Hm = Bm−1 .
F denotes the residual function, Wm is the weight set to
B0 = fext (x), (1) be learned and R denotes the function of residual build-
where fext denotes the feature extraction function and B0 ing block. Specifically, each residual function contains two
is the extracted feature to be sent to the first memory block. convolutional layers with the pre-activation structure [13],
Supposing M memory blocks are stacked to act as the fea- r−1 2 1 r−1
F(Hm , Wm ) = Wm τ (Wm τ (Hm )), (6)
ture mapping, we have
where τ denotes the activation function, including batch
Bm = Mm (Bm−1 ) = Mm (Mm−1 (...(M1 (B0 ))...)), i
normalization [16] followed by ReLU [30], and Wm ,i =
(2)
1, 2 are the weights of the i-th convolutional layer. The bias
where Mm denotes the m-th memory block function and
terms are omitted for simplicity.
Bm−1 and Bm are the input and output of the m-th mem-
Then, several recursions are recursively learned to gen-
ory block respectively. Finally, instead of learning the direct
erate multi-level representations under different receptive
mapping from the low-quality image to the high-quality im-
fields. We call these representations as the short-term mem-
age, our model uses a convolutional layer in ReconNet to
ory. Supposing there are R recursions in the recursive unit,
reconstruct the residual image [20, 21, 40]. Therefore, our
the r-th recursion in recursive unit can be formulated as,
basic MemNet can be formulated as,
r
Hm = R(r)
m (Bm−1 ) = Rm (Rm (...(Rm (Bm−1 ))...)), (7)
y = D(x) | {z }
(3) r
= frec (MM (MM −1 (...(M1 (fext (x)))...))) + x,
where r-fold operations of Rm are performed and
where frec denotes the reconstruction function and D de- {Hmr R
}r=1 are the multi-level representations of the re-
notes the function of our basic MemNet. cursive unit. These representations are concatenated as
Given a training set {x(i) , x̃(i) }N
i=1 , where N is the num- the short-term memory: Bm short
= [Hm 1 2
, Hm R
, ..., Hm ].
ber of training patches and x̃(i) is the ground truth high- In addition, the long-term memory coming from the pre-
quality patch of the low-quality patch x(i) , the loss function vious memory blocks can be constructed as: Bm long
=
of our basic MemNet with the parameter set Θ, is [B0 , B1 , ..., Bm−1 ]. The two types of memories are then
N concatenated as the input to the gate unit,
1 X (i)
L(Θ) = kx̃ − D(x(i) )k2 , (4) gate short long
2N i=1 Bm = [Bm , Bm ]. (8)
...
...
ReconNet
wm Final
Output m
Output
...
...
Input FENet Memory block 1 ... Memory block m ... Memory block M Output M wM
Skip connection from input Long path transmission to Transmission from memory
Short path transmission
to the ReconNet the gate unit block to ReconNet
Figure 3. Multi-supervised MemNet architecture. The outputs with purple color are supervised.
gate MemNet_NL_4 MemNet_NL_6 MemNet_4 MemNet_6
where fm and Bm denote the function of the 1 × 1 con-
gate
volutional layer (parameterized by Wm ) and the output
of the m-th memory block, respectively. As a result, the (a)
weights for the long-term memory controls how much of
the previous states should be reserved, and the weights for
the short-term memory decides how much of the current 27.31/0.9078 27.45/0.9101 27.29/0.9070 27.71/0.9142
state should be stored. Therefore, the formulation of the
m-th memory block can be written as,
(b)
Bm = Mm (Bm−1 )
= fgate ([Rm (Bm−1 ), ..., R(R)
m (Bm−1 ), B0 , ..., Bm−1 ]).
Low frequency High frequency
(10)
3.3. Multi-Supervised MemNet (c)
To further explore the features at different states, inspired
by [21], we send the output of each memory block to the MemNet_NL_4-MemNet_NL_6 MemNet_4-MemNet_6 MemNet_4-MemNet_NL_4 MemNet_6-MemNet_NL_6
same reconstruction net fˆrec to generate
Figure 4. (a) ×4 super-resolved images and PSNR/SSIMs of dif-
ym = fˆrec (x, Bm ) = x + frec (Bm ), (11) ferent networks. (b) We convert 2-D power spectrums to 1-D spec-
tral densities by integrating the spectrums along each concentric
where {ym }M m=1 are the intermediate predictions. All of circle. (c) Differences of spectral densities of two networks.
the predictions are supervised during training, and used
to
PM compute the final output via weighted averaging: y = high-frequency signals. To verify our intuition, we train
M
m=1 wm · ym (Fig. 3). The optimal weights {wm }m=1 a 80-layer MemNet without long-term connections, which
are automatically learned during training and the final out- is denoted as MemNet NL, and compare with the original
put from the ensemble is also supervised. The loss function MemNet. Both networks have 6 memory blocks leading to
of our multi-supervised MemNet can be formulated as, 6 intermediate outputs, and each memory block contains 6
N M
recursions. Fig. 4(a) shows the 4th and 6th outputs of both
α X (i) X (i) 2 networks. We compute their power spectrums, center them,
L(Θ) = kx̃ − wm · ym k
2N i=1 m=1
estimate spectral densities for a continuous set of frequency
(12) ranges from low to high by placing concentric circles, and
M N
1 − α X X (i) (i) 2 plot the densities of four outputs in Fig. 4(b).
+ kx̃ − ym k ,
2M N m=1 i=1
We further plot differences of these densities in Fig. 4(c).
where α denotes the loss weight. From left to right, the first case indicates the earlier layer
does contain some mid-frequency information that the latter
3.4. Dense Connections for Image Restoration layers lose. The 2nd case verifies that with dense connec-
Now we analyze why the long-term dense connections tions, the latter layer absorbs the information carried from
in MemNet may benefit the image restoration. In very the previous layers, and even generate more mid-frequency
deep networks, some of the mid/high-frequency informa- information. The 3rd case suggests in earlier layers, the
tion can get lost at latter layers during a typical feedfor- frequencies are similar between two models. The last case
ward CNN process, and dense connections from previ- demonstrates the MemNet recovers more high frequency
ous layers can compensate such loss and further enhance than the version without long-term connections.
4. Discussions Methods MemNet NL MemNet NS MemNet
×2 37.68/0.9591 37.71/0.9592 37.78/0.9597
Difference to Highway Network First, we discuss how ×3 33.96/0.9235 34.00/0.9239 34.09/0.9248
the memory block accomplishes the gating mechanism and ×4 31.60/0.8878 31.65/0.8880 31.74/0.8893
present the difference between MemNet and Highway Net- Table 1. Ablation study on effects of long-term and short-term con-
work – a very deep CNN model using a gate unit to regulate nections. Average PSNR/SSIMs for the scale factor ×2, ×3 and
×4 on dataset Set5. Red indicates the best performance.
information flow [32].
To avoid information attenuation in very deep plain net-
works, inspired by LSTM, Highway Network introduced
the bypassing layers along with gate units, i.e.,
where a and b are the input and output, A and T are two (a) Image denoising
non-linear transform functions. T is the transform gate to
control how much information produced by A should be
stored to the output; and 1 − T is the carry gate to decide
how much of the input should be reserved to the output.
In MemNet, the short-term and long-term memories are
concatenated. The 1 × 1 convolutional layer adaptively
learns the weights for different memories. Compared to
(b) Super-resolution
Highway Network that learns specific weight for each pixel,
our gate unit learns specific weight for each feature map,
which has two advantages: (1) to reduce model parameters
and complexity; (2) to be less prone to overfitting.
Difference to DRCN There are three main differences be-
tween MemNet and DRCN [21]. The first is the design of
the basic module in network. In DRCN, the basic module
is a convolutional layer; while in MemNet, the basic mod- (c) JPEG deblocking
ule is a memory block to achieve persistent memory. The Figure 5. The norm of filter weights vm l
vs. feature map index l.
second is in DRCN, the weights of the basic modules (i.e., For the curve of the mth block, the left (m × 64) elements denote
the convolutional layers) are shared; while in MemNet, the long-term memories and the rest (Lm − m × 64) elements
the weights of the memory blocks are different. The third denote the short-term memories. The bar diagrams illustrate the
is there are no dense connections among the basic mod- average norm of long-term memories, short-term memories from
ules in DRCN, which results in a chain structure; while in the first R − 1 recursions and from the last recursion, respectively.
MemNet, there are long-term dense connections among the E.g., each yellow bar is the average norm of the short-term mem-
memory blocks leading to the multi-path structure, which ories from the last recursion in the recursive unit (i.e., the last 64
not only helps information flow across the network, but elements in each curve).
also encourages gradient backpropagation during training.
Benefited from the good information flow ability, MemNet
5. Experiments
could be easily trained without the multi-supervision strat- 5.1. Implementation Details
egy, which is imperative for training DRCN [21]. Datasets For image denoising, we follow [27] to use
Difference to DenseNet Another related work to MemNet 300 images from the Berkeley Segmentation Dataset
is DenseNet [14], which also builds upon a densely con- (BSD) [28], known as the train and val sets, to generate
nected principle. In general, DenseNet deals with object image patches as the training set. Two popular benchmarks,
recognition, while MemNet is proposed for image restora- a dataset with 14 common images and the BSD test set with
tion. In addition, DenseNet adopts the densely connected 200 images, are used for evaluation. We generate the input
structure in a local way (i.e., inside a dense block), while noisy patch by adding Gaussian noise with one of the three
MemNet adopts the densely connected structure in a global noise levels (σ = 30, 50 and 70) to the clean patch.
way (i.e., across the memory blocks). In Secs. 3.4 and 5.2, For SISR, by following the experimental setting in [20],
we analyze and demonstrate the long-term dense connec- we use a training set of 291 images where 91 images are
tions in MemNet indeed play an important role in image from Yang et al. [38] and other 200 are from BSD train set.
restoration tasks. For testing, four benchmark datasets, Set5 [1], Set14 [39],
(sec.)
Dataset VDSR [20] DRCN [21] RED [27] MemNet MemNet_M6
MemNet_M5
Depth 20 20 30 80
Filters 64 256 128 64 MemNet_M4
5.4. Comparision with Non-Persistent CNN Models (sec.) when processing a 288 × 288 image on GPU P40.
In this subsection, we compare MemNet with three Results of VDSR [20] and DRCN [21] are cited from their
existing non-persistent CNN models, i.e., VDSR [20], papers. RED [27] is skipped here since its high number of
DRCN [21] and RED [27], to demonstrate the superior- parameters may reduce the contrast among other methods.
ity of our persistent memory structure. VDSR and DRCN We see that our MemNet already achieve comparable re-
are two representative networks with the plain structure sult at the 3rd prediction using much fewer parameters, and
and RED is representative for skip connections. Tab. 2 significantly outperforms the state of the arts by slightly in-
presents the published results of these models along with creasing model complexity.
their training details. Since the training details are differ- 5.5. Comparisons with State-of-the-Art Models
ent among different work, we choose DRCN as a baseline, We compare multi-supervised 80-layer MemNet with the
which achieves good performance using the least training state of the arts in three restoration tasks, respectively.
images. But, unlike DRCN that widens its network to in- Image Denoising Tab. 3 presents quantitative results on
crease the parameters (filter number: 256 vs. 64), we deepen two benchmarks, with results cited from [27]. For BSD200
our MemNet by stacking more memory blocks (depth: 20 dataset, by following the setting in RED [27], the origi-
vs. 80). It can be seen that, using the fewest training images nal image is resized to its half size. As we can see, our
(91), filter number (64) and relatively few model parameters MemNet achieves the best performance on all cases. It
(667K), our basic MemNet already achieves higher PSNR should be noted that, for each test image, RED rotates and
than the prior networks. Keeping the setting unchanged, mirror flips the kernels, and performs inference multiple
our multi-supervised MemNet further improves the perfor- times. The outputs are then averaged to obtain the final
mance. With more training images (291), our MemNet sig- result. They claimed this strategy can lead to better perfor-
nificantly outperforms the state of the arts. mance. However, in our MemNet, we do not perform any
Since we aim to address the long-term dependency prob- post-processing. For qualitative comparisons, we use public
lem in networks, we intend to make our MemNet very deep. codes of PCLR [2], PGPD [37] and WNNM [9]. The results
However, MemNet is also able to balance the model com- are shown in Fig. 7. As we can see, our MemNet handles
plexity and accuracy. Fig. 6 presents the PSNR of different Gaussian noise better than the previous state of the arts.
intermediate predictions in MemNet (e.g., MemNet M3 de- Super-Resolution Tab. 4 summarizes quantitative results
notes the prediction of the 3rd memory block) for scale ×3 on four benchmarks, by citing the results of prior methods.
on Set5, in which the colorbar indicates the inference time MemNet outperforms prior methods in almost all cases.
Ground Truth Noisy PCLR PGPD WNNM MemNet (ours) Ground Truth JPEG ARCNN TNRD DnCNN MemNet (ours)
(PSNR/SSIM) (18.56/0.2953) (29.89/0.8678) (29.80/0.8652) (29.93/0.8702) (30.48/0.8791) (PSNR/SSIM) (25.79/0.7621) (26.92/0.7971) (27.24/0.8104) (27.59/0.8161) (28.15/0.8353)
“206062” from BSD200 with noise level 70. Only MemNet cor- Figure 9. Qualitative comparisons of JPEG deblocking. The first
rectly recovers the pillar. Please zoom in to see the details. row shows image “barbara” from Classic5 with quality factor 10.
Ground Truth Bicubic SRCNN VDSR DnCNN MemNet (ours) MemNet recovers the lines, while others give blurry results. The
second row shows image “lighthouse” from LIVE1 with quality
factor 10. MemNet accurately removes the blocking artifact.