The role of locality and weight sharing in convolutional neural networks
Authors: Francesco Mori, Melanie Weber
Organizations: Center of Mathematical Sciences and Applications, Harvard University · John A. Paulson School of Engineering and Applied Sciences, Harvard University
The success of convolutional neural networks is often attributed to locality and weight sharing. However, how these two properties separately shape learning, and how their effects depend on the spatial correlations of natural images, remain poorly understood. We address these questions in a teacher-student model with a convolutional teacher acting on P input positions with correlation c between positions. We compare convolutional and locally connected students trained by online stochastic gradient descent, and derive ordinary differential equations that describe their dynamics exactly in the limit of large feature dimension D. For uncorrelated positions (c=0), the two students follow the same learning trajectory, with the convolutional student learning exactly P times faster. We also find that locality affects the sample complexity: a student that matches the kernel size of the teacher recovers it from OD(D) samples, whereas OD(Dlog(D)) samples are needed with a larger kernel. For c>0, spatial correlations can reduce the advantage of weight sharing. The asymptotic error of the convolutional student grows with c, whereas that of the locally connected student is independent of c and overall lower when evaluated at the same learning rate. When the learning rate is instead tuned to the training horizon, however, the locally connected student wins at early times and the convolutional student at late times, with a transition that we predict analytically.
Figures & tables
Figure 1: Teacher and the two student architectures with P input positions. Colors indicate weight sharing. The teacher is a two-layer CNN with kernel size kt . The CNN student has kernel size ks and weight sharing. The LCN has the same receptive fields as the CNN but no weight sharing. Boundary conditions are cyclic. Here, P=4 , ks=3 , and kt=2 .
Figure 2: Generalization errors εgCNN(α) of the CNN and εgLCN(Pα) of the LCN. Lines are the order-parameter ODEs and symbols mark simulations of a single SGD trajectory. Insets show the ODE curves without the time rescaling. (a) For independent positions ( c=0 ) the trajectories coincide. (b) In the presence of spatial correlations ( c=0.5 ) the rescaling fails and the LCN converges faster (see inset). Parameters: g=\erf , kt=2 , ks=3 , P=4 , η=1 , σ=0 , T=1 , SGD at D=1000 .
Figure 3: CNN students that match the teacher kernel size ( ks=kt ) learn with OD(D) samples, while students with ks>kt take OD(DlogD) samples. (a) Generalization error vs. training time α for three kernel sizes, obtained by integrating the ODEs ( 17 ) from the order parameters of a random initialization at dimension D . (b) Specialization time αspec (Eq. ( 25 ), with γth=0.99 ) against the feature dimension D . Markers are averages over random initializations, each obtained by integrating the ODEs ( 17 ) from the order parameters of a random initialization at dimension D . Standard errors are smaller than the marker size. Lines are fits a+blnD . Parameters: D=1012 in panel (a), g=\erf , kt=1 , P=6 , S=I , η=0.5 , T=1 , σ=0 , 128 random initial conditions in panel (b).
Figure 4: Alignment γs of the CNN kernel with the solution s vs. training time α , for (a) ks=3 and (b) ks=4 . The dotted line marks the specialization time αspec and the dashed line γs=0 . Insets: probability ps that solution s is selected, over 4096 random initial conditions (dashed line: uniform). All curves are solutions of the ODEs ( 17 ). Parameters: D=1012 , g=\erf , kt=1 , P=6 , S=I , η=0.5 , T=1 , σ=0 .
Figure 5: Asymptotic noise floor ε∞/(ησ2) of the CNN and the LCN at kernel size ks=kt=2 , as a function of the data correlation c and the number of positions P , where ε∞ is the asymptotic generalization error under label noise. Lines are the closed forms ( 31 ) and ( 32 ) and markers are the noise floors located numerically from the order-parameter ODEs at finite learning rate. (a) Floor vs. c at P=6 . The CNN grows steeply with c while the LCN stays flat. (b) Scaling with P at c=0 . The CNN and the LCN coincide and are both linear in P . (c) Scaling with P at c=0.5 . The LCN is still linear in P while the CNN grows quadratically. Parameters: g=\erf , ks=kt=2 , η=2×10−3 , σ=1 , T=1 .
Figure 6: Comparison of the CNN and the LCN at training horizon αF and correlation c , each at its optimal constant learning rate. The color shows the log-ratio of the errors ε∗ . Solid line: boundary εCNN∗=εLCN∗ , obtained by integrating the ODEs numerically. Dashed line: analytical prediction Eq. ( 30 ) of the early-time expansion. Parameters: g=\erf , P=4 , ks=kt=1 , T=1 , σ=1 , random initial condition in the limit D→∞ .
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 7: Specialization time of the CNN against the feature dimension, as in Figure 3(b) . Color denotes the student kernel size. Markers are averages over random initializations, each obtained by integrating the ODEs ( 17 ) from the order parameters of a random initialization at dimension D . Standard errors are smaller than the marker size. Lines are fits a+blnD . (a) A teacher of kernel size kt=2 . The matched case ks=kt=2 is flat in D and the two wider kernels grow logarithmically. (b) Correlated positions, at kt=1 , with c=0 faded and c=0.5 at full strength. The plateau at ks>kt survives the correlation. Parameters: g=\erf , P=6 , η=0.5 in panel (a) and η=0.2 in panel (b), T=1 , σ=0 , c=0 in panel (a), D from 106 to 1010 , 128 random initial conditions.
Figure 8: (a) Optimal learning rate η∗ and (b) corresponding generalization error ε∗ (Section 4.3 ) against the training horizon αF , for the CNN and the LCN at three values of the correlation c , from the same ODE solutions as Figure 6 . Parameters: g=\erf , P=4 , ks=kt=1 , T=1 , σ=1 , random initial condition in the limit D→∞ .
Figure 9: Phase diagram of Figure 6 for other parameter values. The color shows log10(εCNN∗/εLCN∗) on a common scale. Solid line: boundary εCNN∗=εLCN∗ , obtained by integrating the ODEs numerically. Dashed line: analytical prediction c=c0αF of the early-time expansion, Eq. ( 30 ). Each panel changes one parameter of Figure 6 : (a) P=8 , (b) ks=kt=2 , (c) T=2 , (d) σ=2 . Other parameters: g=\erf , P=4 , ks=kt=1 , T=1 , σ=1 , random initial condition in the limit D→∞ .
Figure 10: Rescaled noise floor ε∞/(ησ2) of the two students with the ReLU activation, where ε∞ is the asymptotic generalization error under label noise. It is measured by online SGD from the specialized initial condition and averaged over seeds, with the generalization error computed exactly from the student weights. Standard errors are smaller than the marker size. As for \erf (Figure 5 ), the CNN’s floor grows with the data correlation c while the LCN’s stays flat. Parameters: g(z)=max(0,z) , ks=kt=2 , P=4 , D=400 , η=0.1 , T=1 , σ=1 , runs up to α=800 , 8 seeds.
Figure 11: Rescaling test of Figure 2 with the ReLU activation. Generalization errors εgCNN(α) of the CNN and εgLCN(Pα) of the LCN, from online SGD averaged over 16 runs per student. Standard errors are smaller than the marker size. Insets show the curves without the time rescaling. (a) c=0 . (b) c=0.5 . Parameters: g(z)=max(0,z) , kt=2 , ks=3 , P=4 , η=0.2 , σ=0 , T=1 , D=1000 .
Convolutional neural networks (CNNs) learn spatial and temporal patterns using shared filters, with applications from image recognition to scientific prediction.