AI Logic

Convolution Types

Octave Convolution (OctConv)

Updated:

How octave convolution works. The left side shows its use in a network: the first OctConv splits the feature map into high and low frequencies, the middle OctConv is repeated, and the last OctConv merges them back into one. The right side shows the four paths of one layer: from the input's high frequency (8 × 8) and low frequency (4 × 4, coarse cells of the same overall size) at the bottom, two convolutions within the same frequency and two inter-frequency exchanges using average pooling and upsampling are summed into the output's high and low frequencies at the top

Background and Overview

Octave convolution (OctConv) is a convolution that splits the channels of a feature map into a "finely varying high frequency" and a "slowly varying low frequency," and stores and processes the low-frequency part at half the resolution in each dimension. It was proposed by Chen et al. at Facebook AI in 2019. A notable feature is that it reduces computation and memory while often improving accuracy.

Natural images can be viewed as a combination of fine details such as edges and textures (high frequency) and slowly changing regions such as sky or walls (low frequency). The same holds for CNN feature maps: some channels have nearly identical values at neighboring positions. Storing such channels at full resolution is wasteful.

The idea is the same as saving a photo: fine textures need high resolution, but smooth regions can be stored coarsely with almost no visible difference. The name "octave" comes from music, where going up one octave doubles the frequency; likewise, the low-frequency part has 1/2 the resolution of the high-frequency part.

Octave convolution can be used as a drop-in replacement for ordinary convolution, with no need to change the network architecture. On ResNet, ResNeXt, DenseNet, SENet, MobileNet, and others, it reduced computation on ImageNet while maintaining or improving accuracy.

Mechanism and Computation

A feature map with cc channels and size h×wh \times w is split into two parts by the ratio α\alpha (0≤α≤10 \le \alpha \le 1) of channels assigned to the low frequency.

XH∈R(1−α)c×h×w,XL∈Rαc×h2×w2X^H \in \mathbb{R}^{(1-\alpha)c \times h \times w}, \qquad X^L \in \mathbb{R}^{\alpha c \times \frac{h}{2} \times \frac{w}{2}}

XHX^H is the high frequency (fine detail) and XLX^L the low frequency (slow variation); the low frequency is stored at half the resolution in both height and width. Octave convolution takes these two as input and outputs two of the same shape.

  1. Split the kernel into four: Split the ordinary convolution kernel WW into four parts, WH→HW^{H \to H}, WL→HW^{L \to H}, WL→LW^{L \to L}, and WH→LW^{H \to L}, according to whether the input and output are high or low frequency. Together, the four have the same number of weights as the ordinary convolution.
  2. Update within the same frequency: Convolve XHX^H with WH→HW^{H \to H} and XLX^L with WL→LW^{L \to L}, each at its own resolution.
  3. Pass from low to high frequency: Convolve XLX^L with WL→HW^{L \to H} at half resolution, then upsample the result by 2× with nearest-neighbor interpolation.
  4. Pass from high to low frequency: Apply 2×2 average pooling with stride 2 to XHX^H to halve its resolution, then convolve with WH→LW^{H \to L}.
  5. Sum: Add the two results arriving at each frequency to obtain the outputs YHY^H and YLY^L.

In equation form (Equation 4 in the paper, where f(X;W)f(X; W) is convolution with kernel WW):

YH=f(XH;WH→H)+upsample⁡(f(XL;WL→H), 2)YL=f(XL;WL→L)+f(pool⁡(XH,2); WH→L)\begin{aligned} Y^H &= f(X^H; W^{H \to H}) + \operatorname{upsample}\bigl(f(X^L; W^{L \to H}),\, 2\bigr) \\ Y^L &= f(X^L; W^{L \to L}) + f\bigl(\operatorname{pool}(X^H, 2);\, W^{H \to L}\bigr) \end{aligned}

The key design choice is placing the upsampling after the convolution. Restoring the low frequency to full resolution before convolving would bring back all the computation saved by compression.

When inserting it into a network, the ratios change as follows. α\alpha is a single value for the whole network.

PositionInput ratio αin\alpha_{\text{in}}Output ratio αout\alpha_{\text{out}}Paths used
First OctConv0 (ordinary feature map)α\alphaTwo: H→H and H→L
Middle OctConvα\alphaα\alphaAll four
Last OctConvα\alpha0 (back to an ordinary feature map)Two: H→H and L→H

In the paper's experiments, the first convolution before max pooling is not replaced. With grouped convolution, all four convolutions become grouped convolutions; with depthwise convolution (the first half of depthwise separable convolution), the inter-frequency paths disappear and only two depthwise convolutions remain.

Why It Works: The Low Frequency Can Be Coarse

Octave convolution reduces computation without losing accuracy for the following three reasons.

Low-frequency channels lose almost no information when their resolution is lowered

Slowly varying channels have nearly the same values over neighboring 2×2 positions, so merging them into one causes no problem. When the paper analyzed feature maps with the Fourier transform, the low-frequency group contained almost no high-frequency components, while the high-frequency group contained both high and low frequencies. Since the high-frequency side can also carry low-frequency information when needed, the flexibility of learning is preserved.

Computation and memory drop in proportion to the reduced resolution

Three of the four paths are computed at half resolution (1/4 the number of positions), so computation and memory relative to an ordinary convolution are as follows (Appendix B of the paper).

Computation ratio=1−34α(2−α),Memory ratio=1−34α\text{Computation ratio} = 1 - \tfrac{3}{4}\alpha(2 - \alpha), \qquad \text{Memory ratio} = 1 - \tfrac{3}{4}\alpha
Low-frequency ratio α\alpha00.1250.250.50.751.0
Computation100%82%67%44%30%25%
Memory100%91%81%63%44%25%

Low-frequency convolution sees twice the range in the original image

A k×kk \times k kernel at half resolution covers a 2k×2k2k \times 2k range at the original resolution. The larger receptive field lets the model use information from distant positions, which can improve recognition accuracy. In the paper, the improvement from octave convolution grew with larger test images (ResNet-50, α=0.5\alpha = 0.5: +0.7 points at 256 pixels and +1.2 points at 740 pixels), which the authors attribute to large objects being easier to capture.

Dilated convolution is another way to enlarge the receptive field. Dilated convolution widens the gaps in the kernel while keeping the resolution, so computation does not drop; octave convolution lowers the resolution, enlarging the receptive field and reducing computation at the same time.

Experimental Results

ResNet-50 (ImageNet, varying the low-frequency ratio, Table 2 in the paper)

Inference times were measured on an Intel Skylake CPU (single thread). The baseline ResNet-50 ran in 119 ms with Intel's library (MKLDNN) and in 115 ms with the same compiler as octave convolution (TVM).

Low-frequency ratio α\alphaTop-1 (%)Computation (GFLOPs)Inference time (ms, TVM)
0 (ordinary ResNet-50)77.04.1115
0.12578.23.6116
0.2578.03.199
0.577.42.474
0.7576.71.961

Accuracy peaked at α=0.125\alpha = 0.125 (+1.2 points), and at α=0.5\alpha = 0.5 it stayed above the baseline even with computation nearly halved. Even with 75% of the channels at half resolution, accuracy dropped by only 0.3 points. ResNet-26, ResNet-101, ResNet-200, ResNeXt, DenseNet-121, and SE-ResNet-50 showed the same trend, with the highest accuracy at α\alpha of 0.125 or 0.25.

Lightweight models (ImageNet, Table 3 in the paper)

Modelα\alphaComputation (M)CPU (ms)Top-1 (%)
MobileNetV1 (0.75)―32513.470.3
Oct-MobileNetV1 (0.75)0.37521311.970.5
MobileNetV2 (1.0)―30024.572.0
Oct-MobileNetV2 (1.0)0.37525617.172.0

MobileNetV1 cut computation by 34% with a slight gain in accuracy, and MobileNetV2 cut it by 15% with the same accuracy.

Large models (ImageNet, Table 5 in the paper)

A ResNet-152 (α=0.125\alpha = 0.125) with octave convolution and SE blocks reached 82.9% top-1 accuracy at 22.2 GFLOPs with 320×320 inputs.

Inter-frequency paths (Oct-ResNet-50, α=0.5\alpha = 0.5, Table 8 in the paper)

SettingTop-1 (%)
No exchange paths76.0
Only one path (L→H or H→L)76.4
Both paths, stride-2 convolution for downsampling76.3
Both paths, max pooling77.0
Both paths, average pooling (default)77.4

Both exchange paths are necessary, and average pooling gave the best results for halving the resolution.

Video action recognition (Kinetics-400, Table 6 in the paper)

For the 3D-convolutional I3D (without ImageNet pretraining), computation dropped from 28.1 to 25.6 GFLOPs and top-1 accuracy rose from 72.6% to 73.6% (α=0.1\alpha = 0.1).

Practical Considerations

Do not use a stride-2 convolution to halve the low frequency. Applying a stride-2 convolution with an odd-sized kernel such as 3×3 and then upsampling shifts the whole feature map toward the bottom right, so it no longer aligns with the unshifted high-frequency result when the two are added. The paper uses average pooling, which was also 1.1 points more accurate than a stride-2 convolution (Oct-ResNet-50, α=0.5\alpha = 0.5).

  • Choose α\alpha according to whether accuracy or computation matters more: As a guideline, use 0.125 to 0.25 to improve accuracy and 0.5 to cut computation substantially. At 0.75 or more, accuracy starts to fall below the baseline.
  • Keep the feature map height and width even: The low frequency is stored at half the height and width, so odd sizes will not match the high frequency.
  • Lightweight models may not speed up as much as their computation suggests: The paper also cautions that the runtime of small models is not determined by computation alone. In Table 3, the widened Oct-MobileNetV2 (1.125, α=0.5\alpha = 0.5) has 295M operations, fewer than the baseline's 300M, yet takes 26.3 ms on CPU, slower than the baseline's 24.5 ms.
  • The first and last layers are handled differently: The first OctConv splits an ordinary feature map into two, and the last OctConv merges them back into one. Right before classification, the feature map must be returned to an ordinary one.

Comparison with Other Convolutions and How to Choose

The table below arranges techniques for reducing convolution cost by the kind of redundancy they remove. Octave convolution differs from the others in removing redundancy in the spatial (positional) dimension, and it can be combined with them.

MethodRedundancy removedHowComputation
Octave convolutionSpatial (overlap between neighboring positions)Stores low-frequency channels at half resolution1−34α(2−α)1 - \tfrac{3}{4}\alpha(2-\alpha)×
Grouped convolutionConnections between channelsSplits channels into gg groups1/g1/g×
Depthwise separable convolutionMixing space and channels at onceSplits into spatial (depthwise) and channel (1×1)About 1/Cout+1/k21/C_{\text{out}} + 1/k^2×
Dilated convolution― (enlarges the receptive field)Widens the gaps in the kernelUnchanged

Compared with networks that use multiple resolutions (bL-Net, Elastic, multigrid convolution, etc.), octave convolution only requires replacing a single convolutional layer. In the paper's comparisons, it achieved higher accuracy than these with similar or less computation (e.g., on ResNeXt-50, 78.8% versus Elastic's 78.4%, with 31% less computation).

Rough guidelines for choosing:

  • Reducing computation without changing the current architecture: Replace convolutions with octave convolutions. α=0.5\alpha = 0.5 nearly halves the computation.
  • Improving accuracy without adding computation: Try octave convolution with α=0.125\alpha = 0.125 to 0.250.25.
  • Going even lighter: Combine it with grouped or depthwise convolution. The paper shows that the combination remains effective on ResNeXt and MobileNet.

PyTorch example

Show code
python
import torch
import torch.nn as nn
import torch.nn.functional as F

# Octave convolution: not built into PyTorch, so it is written following Equation 4 of the paper
#   Y^H = f(X^H; W^{H→H}) + upsample(f(X^L; W^{L→H}), 2)
#   Y^L = f(X^L; W^{L→L}) + f(pool(X^H, 2); W^{H→L})
# alpha_in = 0 means the first layer (input is an ordinary feature map); alpha_out = 0 means the last layer (merges the output back into one)


class OctConv2d(nn.Module):
  def __init__(self, in_ch, out_ch, kernel_size=3, alpha_in=0.5, alpha_out=0.5, padding=1):
    super().__init__()
    lin, lout = int(alpha_in * in_ch), int(alpha_out * out_ch)   # number of low-frequency channels
    hin, hout = in_ch - lin, out_ch - lout                        # number of high-frequency channels
    conv = lambda i, o: nn.Conv2d(i, o, kernel_size, padding=padding, bias=False) if i > 0 and o > 0 else None
    self.hh, self.hl = conv(hin, hout), conv(hin, lout)
    self.lh, self.ll = conv(lin, hout), conv(lin, lout)

  def forward(self, x):
    xh, xl = x if isinstance(x, tuple) else (x, None)
    yh = self.hh(xh) if self.hh else None
    yl = self.hl(F.avg_pool2d(xh, 2)) if self.hl else None          # high → low: average-pool, then convolve
    if xl is not None:
      if self.lh:                                                    # low → high: convolve, then upsample 2x
        up = F.interpolate(self.lh(xl), scale_factor=2, mode="nearest")
        yh = up if yh is None else yh + up
      if self.ll:
        yl = self.ll(xl) if yl is None else yl + self.ll(xl)
    return yh if yl is None else (yh, yl)


x = torch.randn(1, 64, 56, 56)                       # keep height and width even
first = OctConv2d(64, 64, alpha_in=0.0, alpha_out=0.5)  # split an ordinary feature map into two
middle = OctConv2d(64, 64, alpha_in=0.5, alpha_out=0.5)
last = OctConv2d(64, 64, alpha_in=0.5, alpha_out=0.0)   # merge back into one

xh, xl = first(x)
print(xh.shape, xl.shape)  # torch.Size([1, 32, 56, 56]) torch.Size([1, 32, 28, 28])
xh, xl = middle((xh, xl))
print(last((xh, xl)).shape)  # torch.Size([1, 64, 56, 56])

# Same number of weights as an ordinary convolution
count = lambda m: sum(p.numel() for p in m.parameters())
print(count(middle), count(nn.Conv2d(64, 64, 3, bias=False)))  # 36864 36864

# Computation ratio (Appendix B of the paper): 1 - 3/4 * alpha * (2 - alpha)
for a in (0.125, 0.25, 0.5, 0.75):
  print(a, round(1 - 0.75 * a * (2 - a), 2))  # 0.82 0.67 0.44 0.3

FAQ

Q. What value should the low-frequency ratio α take?
A.

In the paper's experiments, accuracy peaked at α = 0.125 or 0.25, and at α = 0.5 accuracy matched or exceeded the baseline even with computation nearly halved. As a guideline, use 0.125 to 0.25 to prioritize accuracy and 0.5 to prioritize reducing computation.

Q. Which channels go into the high and low frequencies?
A.

The channels are simply split by a fixed ratio from the front; what each side holds is determined by learning. Because the low-frequency group is stored at half resolution, it naturally learns to represent slowly varying information. The paper's Fourier analysis also found almost no high-frequency components in the low-frequency group.

Q. Does the number of weights increase?
A.

No. The ordinary convolution kernel is simply split into four parts by the combination of input and output frequencies, so the four together have the same number of weights as an ordinary convolution. What decreases is the computation and the feature map memory.

References

  1. Y. Chen, H. Fan, B. Xu, Z. Yan, Y. Kalantidis, M. Rohrbach, S. Yan, and J. Feng, "Drop an Octave: Reducing Spatial Redundancy in Convolutional Neural Networks with Octave Convolution," ICCV, 2019.
  2. facebookresearch/OctConv (official implementation by the paper's authors)