For an output position p0, a standard convolution computes the following using the set of kernel positions R ({(−1,−1),(−1,0),…,(1,1)} for 3×3) (Eq. 1 of the paper).
y(p0)=pn∈R∑w(pn)⋅x(p0+pn)
Deformable convolution reads the input at each kernel position pn plus an offset Δpn (Eq. 2). N=∣R∣ is the number of kernel positions, 9 for 3×3.
y(p0)=pn∈R∑w(pn)⋅x(p0+pn+Δpn)
The computation proceeds as follows.
- Compute the offsets: apply another convolution (with the same kernel size and dilation as the main one) to the same input feature map to produce a 2N-channel "offset field". For each cell, this gives the vertical and horizontal shifts Δpn for all N positions.
- Determine the sampling positions: for each output cell p0, read at p0+pn+Δpn. Offsets are usually fractional, so the positions fall off cell centers.
- Interpolate values at fractional positions: obtain the value at each such position from the values at the surrounding integer positions by bilinear interpolation (Eqs. 3 and 4).
x(p)=q∑G(q,p)⋅x(q),G(q,p)=g(qx,px)⋅g(qy,py),g(a,b)=max(0,1−∣a−b∣)
G is nonzero only for the 4 cells surrounding p, so the computation is quick.
4. Multiply by the weights and sum: multiply the N interpolated values by the kernel weights w(pn) and sum them into one output cell.
The offset layer and the main weights are learned jointly. Gradients for the offsets are obtained by backpropagation through the bilinear interpolation of Eqs. 3 and 4. The weights of the offset layer are initialized to 0, so training starts from exactly the same computation as a standard convolution.
The offsets are not a single value for the whole layer but values computed from the input for each cell of the image. Even within the same layer, the sampling positions spread out over large objects and contract over small ones. Active Convolution, proposed around the same time, also learns sampling positions, but its offsets are fixed learned values shared across all positions. The paper argues that this difference matters for per-position prediction tasks such as object detection.