Title: WHAT DOES IT TAKE TO GENERATE NATURAL TEXTURES?

Abstract: Natural image generation is currently one of the most actively explored fields in Deep Learning. Many approaches, e.g. for state-of-the-art artistic style transfer or natural texture synthesis, rely on the statistics of hierarchical representations in supervisedly trained deep neural networks. It is, however, unclear what aspects of this feature representation are crucial for natural image generation: is it the depth, the pooling or the training of the features on natural images? We here address this question for the task of natural texture synthesis and show that none of the above aspects are indispensable. Instead, we demonstrate that natural textures of high perceptual quality can be generated from networks with only a single layer, no pooling and random filters.

1. INTRODUCTION:

During the last two years several different approaches towards natural image generation have been suggested, among them generative adversarial networks (Goodfellow et al., 2014; Chen et al., 2016) , probabilistic generative models like the conditional PixelCNN (van den Oord et al., 2016b; a) or maximum entropy models that rely on the representations of deep neural networks (e.g. Gatys et al., 2015b; Johnson et al., 2016; Ulyanov et al., 2016) . The latter approach has been particularly groundbreaking for artistic style transfer and natural texture generation (e.g. Gatys et al., 2015a; b) and has the potential to uncover the regularities that supervisedly trained deep neural networks infer from natural images.

For the sake of clarity and concreteness, this paper will focus on natural texture synthesis. Parametric texture models aim to uniquely describe each texture by a set of statistical measurements that are taken over the spatial extent of the image. Each image with the same spatial summary statistics should be perceived as the same texture. Consequently, synthesizing a texture corresponds to finding a new image that reproduces the summary statistics inferred from the reference texture. Starting from Nth-order joint histograms of the pixels by Julesz (1962) , many different statistical measures have been proposed (see e.g. Heeger & Bergen, 1995; Portilla & Simoncelli, 2000) . The quality of the synthesized textures is usually determined by human inspection; the synthesis is successful if a human observer cannot tell the reference texture from the synthesized ones.

The current state of the art in parametric texture modeling (Gatys et al., 2015a) employs the hierarchical image representation in a deep 19-layer convolutional network (Simonyan & Zisserman (2014) ; in the following referred to as VGG network) that was trained on object recognition in natural images (Russakovsky et al. (2015) ). In this model textures are described by the raw correlations between feature activations in response to the texture image from a collection of network layers (see section 5 for details). Since its initial reception several papers explored which additional elements or constraints can further increase the perceptual quality of the generated textures (Berger & Memisevic, 2016; Liu et al., 2016; Aittala et al., 2016) . In this work we go the opposite way and ask which elements of the original texture synthesis algorithm (Gatys et al., 2015a) are absolutely indispensable.

In particular two aspects have been deemed critical for natural texture synthesis: the hierarchical multi-layer representation of the textures, and the supervised training of the feature spaces. Here we show that neither aspect is imperative for texture modeling and that in fact a single convolutional layer with random features can synthesize textures that often rival the perceptual quality of Gatys et al. (2015a) . This is in contrast to earlier reports (Gatys et al., 2015a) that suggested that networks with random weights fail to generate perceptually interesting images. We suggest that this discrepancy originates from a more elaborate tuning of the optimization procedure (see section 4).

Our main contributions are:

• We present a strong minimal baseline for parametric texture synthesis that solely relies on a single-layer network and random, data-independent filters. • We show that textures synthesized from the baseline are of high quality and often rival state-of-the-art approaches, suggesting that the depth and the pre-training of multi-layer image representations are not as indispensable for natural image generation as has previously been thought. • We test and compare a wide range of single-layer architectures with different filter-sizes and different types of filters (random, hand-crafted and unsupervisedly learnt filters) against the state-of-the-art texture model by Gatys et al. (2015a) . • We utilize a quantitative texture quality measure based on the synthesis loss in the VGGbased model (Gatys et al., 2015a) to replace the common-place evaluation of texture models through qualitative human inspection. • We discuss a formal generalization of maximum entropy models to account for the natural variability of textures with limited spatial extent.

2. CONVOLUTIONAL NEURAL NETWORK:

If not mentioned otherwise, all our models employ single-layer CNNs with standard rectified linear units (ReLUs) and convolutions with stride one, no bias and padding (f -1)/2 where f is the filter-size. This choice ensures that the spatial dimension of the output feature maps is the same as the input. All networks except the last one employ filters of size 11 × 11 × 3 (filter width × filter height × no. of input channels), but the number of feature maps as well as the selection of the filters differ:

• Fourier-363: Each color channel (R, G, B) is filtered separately by each element B i ∈ R 11×11 of the 2D Fourier basis (11×11 = 121 feature maps/channel), yielding 3•121 = 363 feature maps in total. More concretely, each filter can be described as the tensor product B i ⊗ e k where the elements of the unit-norm e k ∈ R 3 are all zero except one. • Fourier-3267: All color channels (R, G, B) are filtered simultaneously by each element B i of the 2D Fourier basis but with different weighting terms w R , w G , w B ∈ [1, 0, -1], yielding 3 • 3 • 3 • 121 = 3267 feature maps in total. More concretely, each filter can be described by the tensor product

B i ⊗ [w R , w G , w B ].

• Kmeans-363: We randomly sample and whiten 1e7 patches of size 11 × 11 from the Imagenet dataset (Russakovsky et al., 2015) , partition the patches into 363 clusters using k-means (Rubinstein et al., 2009) , and use the cluster means as convolutional filters. • Kmeans-3267: Same as Kmeans-363 but with 3267 clusters.

• Kmeans-NonWhite-363/3267: Same as Kmeans-363/3267 but without whitening of the patches. • Kmeans-Sample-363/3267: Same as Kmeans-363/3267, but patches are only sampled from the target texture. • PCA-363: We randomly sample 1e7 patches of size 11 × 11 from the Imagenet dataset (Russakovsky et al., 2015) , vectorize each patch, perform PCA and use the set of principal axes as convolutional filters. • Random-363: Filters are drawn from a uniform distribution according to (Glorot & Bengio, 2010) , 363 feature maps in total. • Random-3267: Same as Random-363 but with 3267 feature maps. Additionally, the first column shows samples from the VGG model (Gatys et al., 2015a) , and the last column from the multi-scale model (with 1024 feature maps). 5, 7, 11, 15, 23, 37, 55 and 128 feature maps each (1024 feature maps in total). Filters are drawn from a uniform distribution according to (Glorot & Bengio, 2010) .

• Random-Multiscale Eight different filter sizes f × f × 3 with f = 3,

The networks were implemented in Lasagne (Dieleman et al., 2015; Theano Development Team, 2016) . We remove the DC component of the inputs by subtracting the mean intensity in each color channel (estimated over the Imagenet dataset (Russakovsky et al., 2015) ).

3. TEXTURE MODEL:

The texture model closely follows (Gatys et al., 2015a) . In essence, to characterise a given vectorised texture x ∈ R M , we first pass x through the convolutional layer and compute the output activations.

The output can be understood as a non-linear filter bank, and thus its activations form a set of filtered images (so-called feature maps). For N distinct feature maps, the rectified output activations can be described by a matrix F ∈ R N ×M . To capture the stationary structure of the textures, we compute the covariances (or, more precisely, the Gramian matrix) G ∈ R N ×N between the feature activations F by averaging the outer product of the point-wise feature vectors,

EQUATION

We will denote G(x) as the Gram matrix of the feature activations for the input x. To determine the relative distance between two textures x and y we compute the euclidean distance of the normalized Gram matrices,

d(x, y) = 1 m,n G mn (x) 2 m,n G mn (y) 2 N i,j=1 (G ij (x) -G ij (y)) 2 .

(2)

To compare with the distance in the raw pixel values, we compute

d p (x, y) = 1 m x 2 m m y 2 m N i=1 (x i -y i ) 2 .

(3)

4. TEXTURE SYNTHESIS:

To generate a new texture we start from a uniform noise image (in the range [0, 1]) and iteratively optimize it to match the Gram matrix of the reference texture. More precisely, let G(x) be the Gram matrix of the reference texture. The goal is to find a synthesised image x such that the squared distance between G(x) and the Gram matrix G(x) of the synthesized image is minimized, i.e.

x = argmin

EQUATION

EQUATION

)

The gradient ∂E(y)/∂y of the reconstruction error with respect to the image can readily be computed using standard backpropagation, which we then use in conjunction with the L-BFGS-B algorithm (Jones et al., 2001-) to solve (4). We leave all parameters of the optimization algorithm at their default value except for the maximum number of iterations (2000) , and add a box constraints with range [0, 1]. In addition, we scale the loss and the gradients by a factor of 10 7 in order to avoid early stopping of the optimization algorithm. 

5. TEXTURE EVALUATION:

Evaluating the quality of the synthesized textures is traditionally performed by human inspection. Optimal texture synthesis should generate samples that humans perceive as being the same texture as the reference. The high quality of the synthesized textures by (Gatys et al., 2015a) suggests that the summary statistics from multiple layers of VGG can approximate the perceptual metric of humans.

Even though the VGG texture representation is not perfect, this allows us to utilize these statistics as a more objective quantification of texture quality.

For all details of the VGG-based texture model see (Gatys et al., 2015a ). Here we use the standard 19-layer VGG network (Simonyan & Zisserman, 2014) with pretrained weights and average-instead of max-pooling1 . We compute a Gram matrix on the output of each convolutional layer that follows a pooling layer. Let G (.) be the Gram matrix on the activations of the -th layer and

EQUATION

)

the corresponding relative reconstruction cost. The total reconstruction cost is then defined as the average distance between the reference Gram matrices and the synthesized ones, i.e.

EQUATION

)

This cost is reported on top of each synthesised texture in Figures 4. To visually evaluate samples from our single-and multi-scale model against the VGG-based model (Gatys et al., 2015a) , we additionally synthesize textures from VGG by minimizing (7) using L-BFGS-B as in section 4.

6. RESULTS:

In Fig. 1 we show textures synthesised from two random single-and multi-scale models, as well as eight other non-random single-layer models for three different source images (top left). For comparison, we also plot samples generated from the VGG model by Gatys et al. (Gatys et al., 2015a) (bottom left). There are roughly two groups of models: those with a small number of feature maps (363, top row), and those with a large number of feature maps (3267, bottom row). Only the multi-scale model employs 1024 feature maps. Within each group, we can differentiate models for which the filters are unsupervisedly trained on natural images (e.g. sparse coding filters from k-means), principally devised filter banks (e.g. 2D Fourier basis) and completely random filters (see sec. 2 for all details). All single-layer networks, except for multi-scale, feature 11 × 11 filters.

Remarkably, despite the small spatial size of the filters, all models capture much of the small-and mid-scale structure of the textures, in particular if the number of feature maps is large. Notably, the scale of these structures extends far beyond the receptive fields of the single units (see e.g. the pebble texture). We further observe that a larger number of feature maps generally increases the perceptual quality of the generated textures. Surprisingly, however, completely random filters perform on par or better then filters that have been trained on the statistics of natural images. This is particularly true for the multi-scale model that clearly outperforms the single-scale models on all textures. The captured structures in the multi-scale model are generally much larger and often reach the full size of the texture (see e.g. the wall).

While the above results show that for natural texture synthesis one neither needs a hierarchical deep network architecture with spatial pooling nor filters that are adapted to the statistics of natural images, we now focus on the aspects that are crucial for high quality texture synthesis. First, we evaluate whether the success of the random multi-scale network arises from the combination of filters on multiple scales or whether it is simply the increased size of its largest receptive fields (55 × 55 vs. 11 × 11) that leads to the improvement compared to the single-scale model. Thus, to investigate the influence of the spatial extend of the filters and the importance of combining multiple filter sizes in one model, we generate textures from multiple single-scale models, where each model has the same number of random filters as the multi-scale model ( 1024) but only uses filters from a single scale of the multi-scale model (Fig. 2 ). We find that while 3 × 3 filters mainly capture the marginal distribution of the color channels, larger filters like 11 × 11 model small-to mid-scale structures (like small stones) but miss more long-range structures (larger stones are not well separated). Very large filters like 55 × 55, on the other hand, are capable of modeling long-range structures but then miss much of the small-to midscale statistics (like the texture of the stone). Therefore we conclude that the combination of different scales in the multi-scale network is important for good texture synthesis since it allows to simultaneously model small-, mid-and long-range correlations of the textures. Finally we note that a further indispensable component for good texture models are the non-linearities: textures synthesised the multi-scale model without ReLU (Fig. 2 , right column) are unable to capture the statistical dependencies of the texture.

The perceptual quality of the textures generated from models with only a single layer and random filters is quite remarkable and surpasses parametric methods like Portilla & Simoncelli (2000) that have been state-of-the-art two years ago (before the use of DNNs). The multi-scale model often rivals the current state of the art (Gatys et al., 2015a) as we show in Fig. 4 where we compare samples synthesized from 20 different textures for the random single-and multi-scale model, as well as VGG.

The multi-scale model generates very competitive samples in particular for textures with extremely regular structures across the whole image (e.g. for the brick wall, the grids or the scales). In part, this effect can be attributed to the more robust optimization of the single-layer model that is less prone to local minima then the optimization in deeper models. This can be seen by initializing the VGG-based synthesis with textures from the single-layer model, which consistently yields superior synthesis results (see Appendix A, Fig. 5 ). In addition, for a few textures such as the grid structures, the VGG-based loss is paradoxically lower for samples from the multi-scale model then for the VGG-based model (which directly optimized the VGG-based loss). This suggests that the naive synthesis performed here favors images that are perceptually similar to the reference texture and thus looses variability (see sec. 7 for further discussion). Nonetheless, samples from the single-layer model still exhibit large perceptual differences, see Fig. 3 . The VGG-based loss (7) appears to generally be an acceptable approximation of the perceptual differences between the reference and the synthesized texture. Only for a few textures, especially those with very regular men-made structures (e.g. the wall or the grids), the VGG-based loss fails to capture the perceptual advantage of the multi-scale synthesis. , 5, 7, 11, 15, 23, 37, 55} and 128 feature maps correspond to filters of each size; and the VGG-based model (Gatys et al., 2015a) . Numbers above figures show the values of the normalized VGG-loss (7) for corresponding textures.

7. DISCUSSION:

We proposed a generative model of natural textures based on a single-layer convolutional neural network with completely random filters and showed that the model is able to qualitatively capture the perceptual differences between natural textures. Samples from the model often rival the current state-of-the-art (Gatys et al., 2015a ) (Fig. 4 , third vs fourth row), even though the latter relies on a high-performance deep neural network with features that are tuned to the statistics of natural images.

Seen more broadly, this finding suggests that natural image generation does not necessarily depend on deep hierarchical representations or on the training of the feature maps. Instead, for texture synthesis, both aspects rather seem to serve as fine-tuning of the image representation.

One concern about the proposed single-layer multi-scale model is its computational inefficiency since it involves convolutions with spatially large filters (up to 55 × 55). A more efficient way to achieve receptive fields of similar size would be to use a hierarchical multi-layer net. We conducted extensive experiments with various hierarchical architectures and while the synthesis is indeed significantly faster, the quality of the synthesized textures does not improve compared to a single-layer model.

Thus for a minimal model of natural textures, deep hierarchical representations are not necessary but they can improve the efficiency of the texture synthesis.

Our results clearly demonstrate that Gram matrices computed from the feature maps of convolutional neural networks generically lead to useful summary statistics for texture synthesis. The Gram matrix on the feature maps transforms the representations from the convolutional neural network into a stationary feature space that captures the pairwise correlations between different features. If the number of feature maps is large, then the local structures in the image are well preserved in the projected space and the overlaps of the convolutional filtering add additional constraints. At the same time, averaging out the spatial dimensions yields sufficient flexibility to generate entirely new textures that differ from the reference on a patch by patch level, but still share much of the small-and long-range statistics.

The success of shallow convolutional networks with random filters in reproducing the structure of the reference texture is remarkable and indicates that they can be useful for parametric texture synthesis. Besides reproducing the stationary correlation structure of the reference image ("perceptual similarity") another desideratum of a texture synthesis is to exhibit a large variety between different samples generated from the same given image ("variability"). Hence, synthesis algorithms need to balance perceptual similarity and variability. This balance is determined by a complex interplay between the choice of summary statistics and the optimization algorithm used. For example the stopping criterion of the optimization algorithm can be adjusted to trade perceptual similarity for larger variability.

Finding the right balance between perceptual similarity and variability is challenging because we are currently lacking robust measures of these quantities. In this work we introduced VGG-loss as a measure of perceptual similarity, and, even though, it works much better than other common measures such as Structural Similarity Index (SSIM, Wang et al., 2004 , see Appendix A, Figure 6 ) or Euclidean distance in the pixel space (not shown), it is still not perfect (Figure 4 ). Measuring variability is probably even more difficult: in principle it requires measuring the entropy of generated samples, which is intractable in a high-dimensional space. A different approach could be based on a psychophysical assessment of generated samples. For example, we could use an inpainting task (illustrated in Appendix A, Figure 7 ) to make human observers decide between actual texture patches and inpaited ones. Performance close to a chance-level would indicate that the texture model produces variable enough samples to capture the diversity of actual patches. The further exploration of variability measures lies, however, beyond the scope of this work.

In this paper we focused on maximizing perceptual similarity only, and it is worth pointing out that additional efforts will be necessary to find an optimal trade-off between perceptual similarity and variability. For the synthesis of textures from the random models considered here, the trade-off leans more towards perceptual similarity in comparison to Gatys et al. (2015a) (due to the simpler optimization) which also explains the superior performance on some samples. In fact, we found some anecdotal evidence (not shown) in deeper multi-layer random CNNs where the reference texture was exactly reconstructed during the synthesis. From a theoretical point of view this is likely a finite size effect which does not necessarily constitute a failure of the chosen summary statistics: for finite size images it is well possible that only the reference image can exactly reproduce all the summary statistics. Therefore, in practice, the Gram matrices are not treated as hard constraints but as soft constraints only. More generally, we do not expect a perceptual distance metric to assign exactly zero to a random pair of patches from the same texture. Instead, we expect it to assign small values for pairs from the same texture, and large values for patches from different textures. Therefore, the selection of constraints is not sufficient to characterize a texture synthesis model but only determines the exact minima of the objective function (which are sought for by the synthesis). If we additionally consider images with small but non-zero distance to the reference statistics, then the set of equivalent textures increases substantially, and the precise composition of this set becomes critically dependent on the perceptual distance metric.

Mathematically, parametric texture synthesis models are described as ergodic random fields that have maximum entropy subject to certain constraints Zhu et al. (1997) ; Bruna & Mallat (2013) ; Zhu et al.

(2000) (MaxEnt framework). Practical texture synthesis algorithms, however, always deal with finite size images. As discussed above, two finite-size patches from the same ergodic random field will almost never feature the exact same summary statistics. This additional uncertainty in estimating the constraints on finite length processes is not thoroughly accounted for by the MaxEnt framework (see discussion on its "ad hockeries" by Jaynes (Jaynes (1982) )). Thus, a critical difference of practical implementations of texture synthesis algorithms from the conceptual MaxEnt texture modeling framework is that they genuinely allow a small mismatch in the constraints. Accordingly, specifying the summary statistics is not sufficient but a comprehensive definition of a texture synthesis model should specify:

1. A metric d(x, y) that determines the distance between any two arbitrary textures x, y.

2. A bipartition P x of the image space that determines which images are considered perceptually equivalent to a reference texture x. A simple example for such a partition is the -environment U (y) := {y : d(y, x) < } and its complement.

This definition is relevant for both under-as well as over-constrained models, but its importance becomes particularly obvious for the latter. According to the Minimax entropy principle for texture modeling suggested by Zhu et al Zhu et al. (1997) , as many constraints as possible should be used to reduce the (Kullback-Leibler) divergence between the true texture model and its estimate. However, for finite spatial size, the synthetic samples become exactly equivalent to the reference texture (up to shifts) in the limit of sufficiently many independent constraints. In contrast, if we explicitly allow for a small mismatch between the summary statistics of the reference image and the synthesized textures, then the set of possible textures does not constitute a low-dimensional manifold but rather a small volume within the pixel space. Alternatively, instead of introducing an -environment it is also possible to extent the MaxEnt framework to allow for variability in the summary statistics (Joan Bruna, personal communication). It will be interesting to compare in the future to what extent the difference between the two approaches can lead to differences in the perceptual appearance of the textures.

Taken together we have shown that simple single-layer CNNs with random filters can serve as the basis for excellent texture synthesis models that outperform previous hand-crafted synthesis models and sometimes even rivals the current state-of-the-art. This finding repeals previous observations that suggested a critical role for the multi-layer representations in trained deep networks for natural texture generation. On the other hand, it is not enough to just use sufficiently many constraints as one would predict from the MaxEnt framework. Instead, for the design of good texture synthesis algorithms it will be crucial to find distance measures for which the -environment around the reference texture leads to perceptually satisfying results. In this way, building better texture synthesis models is inherently related to better quantitative models of human perception.

:

https://github.com/Lasagne/Recipes/blob/master/modelzoo/vgg19.py as accessed on 12.05.2016.

(first row -regular samples, second row -from the estimate)

Figures and Tables:

Figure 1: Influence of the feature maps on texture synthesis performance. (Top) Samples synthesized from several single-layer models with 363 feature maps (see sec. 2) for three different textures (rows). Reference textures are shown in the first column. (Bottom) Samples synthesized from several single-layer models with 3267 feature maps (see sec. 2) for three different textures (rows).Additionally, the first column shows samples from the VGG model(Gatys et al., 2015a), and the last column from the multi-scale model (with 1024 feature maps).

Figure 2: Influence of the scale and the non-linearity on texture synthesis performance. (1st column) Samples from the random multi-scale model for comparison (same as in Fig. 1). (2nd -7th colum) Samples from the random single-scale model with different spatial filter sizes. (Last column) Samples from the random multi-scale model without ReLU nonlinearity.

Figure3: Each row shows the reference texture (left, gray background) and three samples that were synthesized from different (random) initial images using our multi-scale model. Most importantly, the multi-scale model generates samples that are perceptually different. All three textures are taken fromPortilla & Simoncelli (2000).

Figure 4: Each row shows the reference texture (left, gray background) and three samples that were synthesized from different (random) initial images using three different models: single-layer network with 1024 feature maps and random 11x11 filters; multi-scale single layer network with filters of sizes f × f , where f = {3, 5, 7, 11, 15, 23, 37, 55} and 128  feature maps correspond to filters of each size; and the VGG-based model(Gatys et al., 2015a). Numbers above figures show the values of the normalized VGG-loss (7) for corresponding textures.

Peer review (iclr2017):
This paper provides an interesting analysis of the conditions which enable generation of natural looking textures. The results is quite surprising, and analysis is quite thorough. I do think the evaluation methods require more work, but as other reviewers mentioned this could be an interesting line of work moving forwards and does not take too much from this current paper which, I think, should be accepted.