chainer.functions.local_convolution_2d¶
-
chainer.functions.
local_convolution_2d
(x, W, b=None, stride=1)[source]¶ Two-dimensional local convolution function.
Locally-connected function for 2D inputs. Works similarly to convolution_2d, except that weights are unshared, that is, a different set of filters is applied at each different patch of the input. It takes two or three variables: the input image
x
, the filter weightW
, and optionally, the bias vectorb
.Notation: here is a notation for dimensionalities.
n is the batch size.
cI is the number of the input.
cO is the number of output channels.
h and w are the height and width of the input image, respectively.
hO and wO are the height and width of the output image, respectively.
kH and kW are the height and width of the filters, respectively.
- Parameters
x (
Variable
or N-dimensional array) – Input variable of shape (n,cI,h,w).W (
Variable
or N-dimensional array) – Weight variable of shape (cO,hO,wO,cI,kH,kW).b (
Variable
or N-dimensional array) – Bias variable of shape (cO,hO,wO) (optional).stride (int or pair of ints) – Stride of filter applications.
stride=s
andstride=(s, s)
are equivalent.
- Returns
Output variable. Its shape is (n,cI∗cO,hO,wO).
- Return type
Like
Convolution2D
,LocalConvolution2D
function computes correlations between filters and patches of size (kH,kW) inx
. But unlikeConvolution2D
,LocalConvolution2D
has a separate filter for each patch of the input(hO,wO) is determined by the equivalent equation of
Convolution2D
, without any paddingIf the bias vector is given, then it is added to all spatial locations of the output of convolution.
See also
Example
>>> x = np.random.uniform(0, 1, (2, 3, 7, 7)) >>> W = np.random.uniform(0, 1, (2, 5, 5, 3, 3, 3)) >>> b = np.random.uniform(0, 1, (2, 5, 5)) >>> y = F.local_convolution_2d(x, W, b) >>> y.shape (2, 2, 5, 5)