Submanifold sparse convolutional networks
We have implemented a convolutional neural network designed for processing sparse three-dimensional input data. The world we live in is three dimensional so there are a large number of potential applications including 3D object recognition and analysis of space-time objects. In the quest for efficiency, we experiment with CNNs on the 2D triangular-lattice and 3D tetrahedral-lattice.READ FULL TEXT VIEW PDF
We propose Lattice gauge equivariant Convolutional Neural Networks (L-CN...
We use spatially-sparse two, three and four dimensional convolutional
This paper introduces a live object recognition system that serves as a ...
This paper presents a convolutional layer that is able to process sparse...
Image-matched nonseparable wavelets can find potential use in many
Convolutional neural networks (CNNs) perform well on problems such as
Errors in measurements are key to weighting the value of data, but are o...
Submanifold sparse convolutional networks
Submanifold sparse convolutional networks
Convolutional neural networks (CNNs) are powerful tools for understanding data with spatial structure such as photos. They are most commonly used in two dimensions, but they can also be applied more generally. One-dimensional CNNs are used for processing time-series such as human speech . Three dimensional CNNs have been used to analyze movement in 2+1 dimensional space-time[5, 6] and for helping drones find a safe place to land 
. Three dimensional convolutional deep belief networks have been used to recognize objects in 2.5D depth maps.
In , a sparse two-dimensional CNN is implemented to perform Chinese handwriting recognition. When a handwritten character is rendered at moderately high resolution on a two dimensional grid, it looks like a sparse matrix. If we only calculate the hidden units of the CNN that can actually see some part of the input field the pen has visited, the workload decreases. We have extended this idea to implement sparse 3D CNNs 111Software for creating sparse 2, 3 and 4 dimensional CNNs is available at https://github.com/btgraham/SparseConvNet. Moving from two to three dimensions, the curse of dimensionality becomes relevant—an cubic grid contains many more points than an square grid. However, the curse can also be taken to mean that the higher the dimension, the more likely interesting input data is to be sparse.
To motivate the idea of a sparse 3D CNN, imagine you have a loop of string with a knot in it. Mathematically, detecting and classifying knots is a hard problem; a piece of string can be very tangled without actually being knotted. Suppose you are only interested in ‘typical’ knots—humans can quite easily learn to spot the difference between, say, a trefoil knot and a figure of eight knot. If you want to take humans out of the loop, then you could train a 2D CNN to recognize and classify pictures of knots. However, pictures taken from certain angles will not contain enough information to classify the knot due to parts of the string being obscured. Suppose instead that you can trace the path of the string through three dimensional space; you could then use a 3D CNN to classify the knot. The string is essentially one dimensional, so the parts of space that the string visits will be sparse.
The example of the string is just a thought experiment. However, there are many real-world problems, in domains such as robotics and biochemistry, where understanding 3D structure is important and where sparsity is applicable.
Recently there has been an explosion of research into conventional two-dimensional CNNs. This has gone hand-in-hand with a substantial increase in available computing power thanks to GPU computing. For photographs of size , evaluating model C of ’s 19 convolutional layers requires 53 billion multiply-accumulate operations.
Although model C’s input is represented as a 3D array of size
, it is still fundamentally 2D—we can think of it as a 2D array of vectors, with each vector storing an RGB-color value. Model C’s initial convolutional layer consists of 96 convolutional filters of size
, applied with stride 2. Each filter is therefore appliedtimes.
This makes 3D CNNs sound like a terrible idea. Consider adapting model C’s network architecture to accept 3D input with size , i.e. some kind of 3D model where each points has a color. To apply a convolutional filter with the same stride, we would need to apply it 112 more times than in the 2D case, with each application requiring 7 times as many operations. Extending the whole of model C to 3D would increase the computational complexity to 6.1 trillion operations. Clearly if we want to use 3D CNNs, then we need to do some things differently.
Applying the convolutions in Fourier space , or using separable filters  could help, but simply the amount of memory needed to store large 3D grids of vectors would still be a problem. Instead we try two things that work well together. Firstly we use much smaller filters, using network architectures similar to the ones introduced in . The smallest non-trivial filter possible on a cubic lattice has size , covering input sites. In an attempt to improve efficiency, we will also consider the tetrahedral lattice, where the smallest filter is a tetrahedron of size 2 which covers just 4 input sites. Secondly, we will only consider problems where the input is sparse. This saves us from having to have the convolutional filters visit each spatial location. If the interesting part of the input is a 1D curve or a 2D surface, then the majority of the 3D input field will receive only zero-vectors for inputs. Sparse CNNs are more efficient when used with smaller filters, as the hidden layers tend to be sparser.
Each layer of a CNN consists of a finite graph, with a vector of input/hidden units at each site. For regular two dimensional CNNs, the graphs are square grids. The convolutional filters are square-shaped too, and they move over the underlying graph with two degrees of freedom; see Figure2 (i). Similarly, 3D CNNs are normally defined on cubic grids. The convolutional filters are cube-shaped, and they move with three degrees of freedom; see Figure 2 (iii).
In principle we could also build 4D CNNs on hypercubic grids, and so on. However, as the dimension increases, the size of the smallest non-trivial filter is growing exponentially. In the interests of efficiency, we will also consider CNNs with a different family of underlying graphs. In 2D, we can build CNNs based on triangles. For each layer, the underlying graph is a triangular grid, and the convolutional filters are triangular, moving with two degree of freedom; see Figure 3 (ii). In 3D, we can use a tetrahedral grid and tetrahedral filters that move with three degrees of freedom; see Figure 3 (iv). We could extend this to 4D with hypertetrahedrons, etc. In dimensions, the smallest convolutional filters contain only sites, rather than exponentially many.
To describe CNN architecture on these different lattices, we will still use the common “C-MP-…” notation. The counts the number of convolutional filters, measures the linear size of the filters—the number of input sites the convolutional filter covers is , , , on the square, cubic, triangular and tetrahedral lattices, respectively—and denotes the stride. The
measures the linear size of the max-pooling regions. Theis omitted when for convolutions or for pooling. For example, on the tetrahedral lattice means 32 filters of size 2 which cover input sites, followed by max pooling with pooling regions of size , and with adjacent pooling regions overlapping by one.
Sparse CNNs can be thought of as an extension of the idea of sparse matrices. If a large matrix only has small number of non-zero entries per row and per column, then it makes sense to use a special data structure to store the non-zero entries and their locations; this can both dramatically reduce memory requirements and speed up operations such as matrix multiplication. However, if 10% of the entries are non-zero, then the advantages of sparsity may be outweighed by the efficiency which which dense matrix multiplication can be carried out, either using Strassen’s algorithm, or optimized GPU kernels.
The sparse CNN algorithm from  can be tweaked to work efficiently on general lattices. The spatial size of each of the CNN’s data layers is described by a lattice-type graph (similar to the ones in Figure 2). At each spatial location in the grid, there is a dimension-less vector of input or hidden units. Depending on the input, some of the spatial locations will be defined to be active.
A spatial location in the input layer graph is declared active if the location’s vector is not the zero vector.
Declare that a spatial location in a hidden layer is active if any of the spatial location in the layer below from which it receives input are active.
By induction, the dimension-less vectors at each non-active spatial location in the -th hidden layer are all the same; the shared value of the vectors can be pre-computed. We will call this the ground state vector for the -th level. The ground state for the input layer is just the zero vector.
We will now describe the implementation of the sparse convolution for the types of graphs shown in Figure 2. For simplicity, we will focus on case (i), the 2D square grid; the other cases are very similar.
Suppose that an image has input field size , and that the number of active spatial locations is . Suppose an convolutional filter will act on the image, and let and denote the number of input and output features per spatial location. The input to the first convolutional operation consists of:
A matrix with size . Each row corresponds to the vector at one of the active spatial locations.
A map or hash table of (key,value) pairs. The keys are the active spatial locations. The values record the number of the corresponding row in .
The input layer’s ground state vector .
An matrix containing the weights that define the convolution.
A vector of length specifying the values of the bias units.
To calculate the output of the first hidden layer:
Iterate through and determine the number of active spatial locations in the output layer. A site in the output layer is active if any of the input sites are active. Build a hash table to uniquely identify each of the active output spatial locations with one of the integers .
Use , and to build a matrix of size ; each row of should correspond to the inputs visible to the convolutional filter at the corresponding output spatial location.
We implemented step 1 on the CPU and steps 2 and 3 on the GPU. If is small, the computational bottleneck will be I/O-related, steps 1 and 2. If is large, the bottleneck will be performing the dense matrix multiplication in step 3 to calculate .
The procedure for max-pooling is similar. Max-pooling is always I/O-bound.
We have performed experiments to test triangular and sparse 3D CNNs. Unlike the 2D case, there are not yet any standard benchmarks for evaluating 3D CNNs, so we just picked a range of different types of data. When faced with a trade-off between computational cost and accuracy, we have preferred to train smaller network to see what can be achieved on a limited computational budget, rather than trying to maximize performance at any cost.
For some of the experiments we used -fold repetitive testing: we processed each test case times, with some form of data augmentation, for a small integer, and averaged the output.
As a sanity test regarding our unusually shaped CNNs, we first did a 2D experiment with the CIFAR-10 dataset of small pictures  to compare CNNs on the square and triangular lattices. We will call the networks SquareNet and TriangLeNet, respectively. Both networks have 12 small convolutional layers split into pairs by 5 layers of max-pooling, and with the -th pair of convolutional filters each having 32 output features:
We extended the training data using affine transformations. For the triangular lattice, we converted the images to triangular coordinates using an additional affine transformation. See Table 1 for the results.
TriangLeNet has a computational cost that is 26% lower than the more conventional SquareNet. In terms of test errors, there does not seem to be any real difference between the two networks.
|CNN||MegaOps||test error||12-fold test error|
To test the 3D CNN, we used a dataset of 3D objects222SHREC2015 Non-rigid 3D Shape Retrieval dataset http://www.icst.pku.edu.cn/zlian/shrec15-non-rigid/data.html
, each stored as a mesh of triangles in the OFF-file format. The dataset contains 1200 exemplars split evenly between 50 classes (aliens, ants, armadillo, …). The dataset was intended to be used for unsupervised learning, but as CNNs are most often used for supervised learning, we used 6-fold cross-validation to measure the ability of our 3D CNNs to learn shapes. To stop the dataset being too easy, we randomly rotated the objects during training and testing. This is to force the CNN to truly learn to recognize shape, and not rely on some classes of objects tending to have a certain orientation.
All the CNNs we tested took the form
We rendered the 3D models at a variety of different scales, and varied the number of levels of pooling accordingly. We tried using MP3/2 pooling on the cubic and tetrahedral lattices. We also tried a stochastic form of max-pooling on the cubic lattice which we denote FMP; we used FMP to downsample the hidden layer by a factor of ; this allows us to gently increase the number of learnt layers for a given input scale. See Figure 5.
The tetrahedral CNNs are substantially cheaper computationally, but less accurate at the smallest scale. The FMP pooling provides the highest accuracy when the scale is small, but they are quite a bit more expensive. If we look at the number of test samples that can be processed per second, we see that for such small CNNs the calculations are actually I/O-bound, so tetrahedral network is not as much faster as we might have expected based on the computational cost. However, with a less powerful processor, it is likely that there would be a speed advantage to the tetrahedral lattice.
The CASIA-OLHWDB1.1 database contains online handwriting samples of the 3755 GBK level-1 Chinese characters . There are approximately 240 training characters, and 60 test characters, per class. Online means that the pen strokes were recorded in the order they were made.
A test error of 5.61% is achieved by drawing the characters with size and learning to recognize their pictures with a 2D CNN . Evaluating that network’s four convolutional layers requires 72 million multiply-accumulate operations.
With a 3D CNN, we can use the order in which the strokes were written to represent each character as a collection of paths in 2+1 dimensional space-time with size . A 3D CNN with architecture
requires on average 118 million operations to evaluate, and produced a test error of 4.93%. We deliberately kept the input spatial size the same, so any improvements would be due to the introduction of the time dimension.
Recognizing actions in videos is another example of a 2+1 dimensional space-time problem. A simple way of turning a video into a sparse 3D object is to take the difference between successive frames, and then setting to zero any values with absolute value below some threshold. We tried this approach on two datasets, the simpler RHA dataset333http://www.nada.kth.se/cvap/actions/  with 6 classes of actions, and the harder UCF101  dataset. We scaled the UCF101 video down by 50% to have the same size as the HRA videos, . In both cases we used a cubic CNN:
For RHA, (mean) accuracy of 71.7% is reported in . We used a threshold of 12%, which resulted in 1.7% of input pixels being active. Our approach yielded 88.0% accuracy with a computational cost of 1.1 billion operations per test case.
For UCF101, accuracy of 43.90% is reported in . We used a threshold of 13%, which resulted in 3.1% of input pixels being active. The computational cost was higher than for RHA, 2.7 billion operatons, as the videos are more complicated. Single testing produced an accuracy of 60.4%, rising to 67.8% with 12-fold testing.
These results are not state of the art. However, they do seem to strike a good balance in terms of computational cost. Also, we have not done any work to try to optimize our results. There are different ways of encoding a video’s ‘optical flow’ that we have not had a chance to explore yet.
We have shown that sparse 3D CNNs can be implemented efficiently, and produce interesting results for a variety of types of 3D data. There are potential applications that we have not yet tried. In biochemisty, there are large databases of 3D molecular structure. Proteins that are encoded differently may fold to produce similar shapes with similar functions. In robotics, it is natural to build 3D models by combining one or more 2D images with depth detector databases. Sparse 3D CNNs could be used to analyse these models.