We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`L.Deconvolution2D` lacks `dilate` option
although `F.deconvolution_2d` already supports it.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `chainer/links/connection/deconvolution_2d.py`
Content:
```
1 import numpy
2 
3 from chainer.backends import cuda
4 from chainer.functions.connection import deconvolution_2d
5 from chainer import initializers
6 from chainer import link
7 from chainer.utils import argument
8 from chainer import variable
9 
10 
11 class Deconvolution2D(link.Link):
12 
13     """__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, groups=1)
14 
15     Two dimensional deconvolution function.
16 
17     This link wraps the :func:`~chainer.functions.deconvolution_2d` function
18     and holds the filter weight and bias vector as parameters.
19 
20     Deconvolution links can use a feature of cuDNN called autotuning, which
21     selects the most efficient CNN algorithm for images of fixed-size, 
22     can provide a significant performance boost for fixed neural nets.
23     To enable, set `chainer.using_config('autotune', True)`
24 
25     Args:
26         in_channels (int or None): Number of channels of input arrays.
27             If ``None``, parameter initialization will be deferred until the
28             first forward data pass at which time the size will be determined.
29         out_channels (int): Number of channels of output arrays.
30         ksize (int or pair of ints): Size of filters (a.k.a. kernels).
31             ``ksize=k`` and ``ksize=(k, k)`` are equivalent.
32         stride (int or pair of ints): Stride of filter applications.
33             ``stride=s`` and ``stride=(s, s)`` are equivalent.
34         pad (int or pair of ints): Spatial padding width for input arrays.
35             ``pad=p`` and ``pad=(p, p)`` are equivalent.
36         nobias (bool): If ``True``, then this function does not use the bias
37             term.
38         outsize (tuple): Expected output size of deconvolutional operation.
39             It should be pair of height and width :math:`(out_H, out_W)`.
40             Default value is ``None`` and the outsize is estimated by
41             input size, stride and pad.
42         initialW (:ref:`initializer <initializer>`): Initializer to
43             initialize the weight. When it is :class:`numpy.ndarray`,
44             its ``ndim`` should be 4.
45         initial_bias (:ref:`initializer <initializer>`): Initializer to
46             initialize the bias. If ``None``, the bias will be initialized to
47             zero. When it is :class:`numpy.ndarray`, its ``ndim`` should be 1.
48         groups (int): The number of groups to use grouped deconvolution. The
49             default is one, where grouped deconvolution is not used.
50 
51     The filter weight has four dimensions :math:`(c_I, c_O, k_H, k_W)`
52     which indicate the number of input channels, output channels,
53     height and width of the kernels, respectively.
54     The filter weight is initialized with i.i.d. Gaussian random samples, each
55     of which has zero mean and deviation :math:`\\sqrt{1/(c_I k_H k_W)}` by
56     default.
57 
58     The bias vector is of size :math:`c_O`.
59     Its elements are initialized by ``bias`` argument.
60     If ``nobias`` argument is set to True, then this function does not hold
61     the bias parameter.
62 
63     The output of this function can be non-deterministic when it uses cuDNN.
64     If ``chainer.configuration.config.cudnn_deterministic`` is ``True`` and
65     cuDNN version is >= v3, it forces cuDNN to use a deterministic algorithm.
66 
67     .. seealso::
68        See :func:`chainer.functions.deconvolution_2d` for the definition of
69        two-dimensional convolution.
70 
71     .. seealso::
72         See :func:`chainer.links.Convolution2D` for the examples of ways to
73         give arguments to this link.
74 
75     .. admonition:: Example
76 
77         There are several ways to make a Deconvolution2D link.
78 
79         Let an input vector ``x`` be:
80 
81         >>> x = np.arange(1 * 3 * 10 * 10, dtype=np.float32).reshape(1, 3, 10, 10)
82 
83         1. Give the first three arguments explicitly:
84 
85             In this case, all the other arguments are set to the default
86             values.
87 
88             >>> l = L.Deconvolution2D(3, 7, 4)
89             >>> y = l(x)
90             >>> y.shape
91             (1, 7, 13, 13)
92 
93         2. Omit ``in_channels`` or fill it with ``None``:
94 
95             The below two cases are the same.
96 
97             >>> l = L.Deconvolution2D(7, 4)
98             >>> y = l(x)
99             >>> y.shape
100             (1, 7, 13, 13)
101 
102             >>> l = L.Deconvolution2D(None, 7, 4)
103             >>> y = l(x)
104             >>> y.shape
105             (1, 7, 13, 13)
106 
107             When you omit the first argument, you need to specify the other
108             subsequent arguments from ``stride`` as keyword arguments. So the
109             below two cases are the same.
110 
111             >>> l = L.Deconvolution2D(None, 7, 4, 2, 1)
112             >>> y = l(x)
113             >>> y.shape
114             (1, 7, 20, 20)
115 
116             >>> l = L.Deconvolution2D(7, 4, stride=2, pad=1)
117             >>> y = l(x)
118             >>> y.shape
119             (1, 7, 20, 20)
120 
121     """  # NOQA
122 
123     def __init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0,
124                  nobias=False, outsize=None, initialW=None, initial_bias=None,
125                  **kwargs):
126         super(Deconvolution2D, self).__init__()
127 
128         groups, = argument.parse_kwargs(
129             kwargs, ('groups', 1),
130             deterministic="deterministic argument is not supported anymore. "
131             "Use chainer.using_config('cudnn_deterministic', value) "
132             "context where value is either `True` or `False`.")
133 
134         if ksize is None:
135             out_channels, ksize, in_channels = in_channels, out_channels, None
136 
137         self.ksize = ksize
138         self.stride = _pair(stride)
139         self.pad = _pair(pad)
140         self.outsize = (None, None) if outsize is None else outsize
141         self.out_channels = out_channels
142         self.groups = int(groups)
143 
144         with self.init_scope():
145             W_initializer = initializers._get_initializer(initialW)
146             self.W = variable.Parameter(W_initializer)
147             if in_channels is not None:
148                 self._initialize_params(in_channels)
149 
150             if nobias:
151                 self.b = None
152             else:
153                 if isinstance(initial_bias, (numpy.ndarray, cuda.ndarray)):
154                     assert initial_bias.shape == (out_channels,)
155                 if initial_bias is None:
156                     initial_bias = 0
157                 bias_initializer = initializers._get_initializer(initial_bias)
158                 self.b = variable.Parameter(bias_initializer, out_channels)
159 
160     def _initialize_params(self, in_channels):
161         kh, kw = _pair(self.ksize)
162         if self.out_channels % self.groups != 0:
163             raise ValueError('the number of output channels must be'
164                              'divisible by the number of groups')
165         if in_channels % self.groups != 0:
166             raise ValueError('the number of input channels must be'
167                              'divisible by the number of groups')
168         W_shape = (in_channels, int(self.out_channels / self.groups), kh, kw)
169         self.W.initialize(W_shape)
170 
171     def forward(self, x):
172         if self.W.array is None:
173             self._initialize_params(x.shape[1])
174         return deconvolution_2d.deconvolution_2d(
175             x, self.W, self.b, self.stride, self.pad, self.outsize,
176             groups=self.groups)
177 
178 
179 def _pair(x):
180     if hasattr(x, '__getitem__'):
181         return x
182     return x, x
183
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/chainer/links/connection/deconvolution_2d.py b/chainer/links/connection/deconvolution_2d.py
--- a/chainer/links/connection/deconvolution_2d.py
+++ b/chainer/links/connection/deconvolution_2d.py
@@ -10,7 +10,7 @@
 
 class Deconvolution2D(link.Link):
 
-    """__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, groups=1)
+    """__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, dilate=1, groups=1)
 
     Two dimensional deconvolution function.
 
@@ -45,6 +45,9 @@
         initial_bias (:ref:`initializer <initializer>`): Initializer to
             initialize the bias. If ``None``, the bias will be initialized to
             zero. When it is :class:`numpy.ndarray`, its ``ndim`` should be 1.
+        dilate (:class:`int` or :class:`tuple` of :class:`int` s):
+            Dilation factor of filter applications.
+            ``dilate=d`` and ``dilate=(d, d)`` are equivalent.
         groups (int): The number of groups to use grouped deconvolution. The
             default is one, where grouped deconvolution is not used.
 
@@ -125,8 +128,8 @@
                  **kwargs):
         super(Deconvolution2D, self).__init__()
 
-        groups, = argument.parse_kwargs(
-            kwargs, ('groups', 1),
+        dilate, groups, = argument.parse_kwargs(
+            kwargs, ('dilate', 1), ('groups', 1),
             deterministic="deterministic argument is not supported anymore. "
             "Use chainer.using_config('cudnn_deterministic', value) "
             "context where value is either `True` or `False`.")
@@ -137,6 +140,7 @@
         self.ksize = ksize
         self.stride = _pair(stride)
         self.pad = _pair(pad)
+        self.dilate = _pair(dilate)
         self.outsize = (None, None) if outsize is None else outsize
         self.out_channels = out_channels
         self.groups = int(groups)
@@ -173,7 +177,7 @@
             self._initialize_params(x.shape[1])
         return deconvolution_2d.deconvolution_2d(
             x, self.W, self.b, self.stride, self.pad, self.outsize,
-            groups=self.groups)
+            dilate=self.dilate, groups=self.groups)
 
 
 def _pair(x):

{"golden_diff": "diff --git a/chainer/links/connection/deconvolution_2d.py b/chainer/links/connection/deconvolution_2d.py\n--- a/chainer/links/connection/deconvolution_2d.py\n+++ b/chainer/links/connection/deconvolution_2d.py\n@@ -10,7 +10,7 @@\n \n class Deconvolution2D(link.Link):\n \n-    \"\"\"__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, groups=1)\n+    \"\"\"__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, dilate=1, groups=1)\n \n     Two dimensional deconvolution function.\n \n@@ -45,6 +45,9 @@\n         initial_bias (:ref:`initializer <initializer>`): Initializer to\n             initialize the bias. If ``None``, the bias will be initialized to\n             zero. When it is :class:`numpy.ndarray`, its ``ndim`` should be 1.\n+        dilate (:class:`int` or :class:`tuple` of :class:`int` s):\n+            Dilation factor of filter applications.\n+            ``dilate=d`` and ``dilate=(d, d)`` are equivalent.\n         groups (int): The number of groups to use grouped deconvolution. The\n             default is one, where grouped deconvolution is not used.\n \n@@ -125,8 +128,8 @@\n                  **kwargs):\n         super(Deconvolution2D, self).__init__()\n \n-        groups, = argument.parse_kwargs(\n-            kwargs, ('groups', 1),\n+        dilate, groups, = argument.parse_kwargs(\n+            kwargs, ('dilate', 1), ('groups', 1),\n             deterministic=\"deterministic argument is not supported anymore. \"\n             \"Use chainer.using_config('cudnn_deterministic', value) \"\n             \"context where value is either `True` or `False`.\")\n@@ -137,6 +140,7 @@\n         self.ksize = ksize\n         self.stride = _pair(stride)\n         self.pad = _pair(pad)\n+        self.dilate = _pair(dilate)\n         self.outsize = (None, None) if outsize is None else outsize\n         self.out_channels = out_channels\n         self.groups = int(groups)\n@@ -173,7 +177,7 @@\n             self._initialize_params(x.shape[1])\n         return deconvolution_2d.deconvolution_2d(\n             x, self.W, self.b, self.stride, self.pad, self.outsize,\n-            groups=self.groups)\n+            dilate=self.dilate, groups=self.groups)\n \n \n def _pair(x):\n", "issue": "`L.Deconvolution2D` lacks `dilate` option\nalthough `F.deconvolution_2d` already supports it.\n", "before_files": [{"content": "import numpy\n\nfrom chainer.backends import cuda\nfrom chainer.functions.connection import deconvolution_2d\nfrom chainer import initializers\nfrom chainer import link\nfrom chainer.utils import argument\nfrom chainer import variable\n\n\nclass Deconvolution2D(link.Link):\n\n    \"\"\"__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, groups=1)\n\n    Two dimensional deconvolution function.\n\n    This link wraps the :func:`~chainer.functions.deconvolution_2d` function\n    and holds the filter weight and bias vector as parameters.\n\n    Deconvolution links can use a feature of cuDNN called autotuning, which\n    selects the most efficient CNN algorithm for images of fixed-size, \n    can provide a significant performance boost for fixed neural nets.\n    To enable, set `chainer.using_config('autotune', True)`\n\n    Args:\n        in_channels (int or None): Number of channels of input arrays.\n            If ``None``, parameter initialization will be deferred until the\n            first forward data pass at which time the size will be determined.\n        out_channels (int): Number of channels of output arrays.\n        ksize (int or pair of ints): Size of filters (a.k.a. kernels).\n            ``ksize=k`` and ``ksize=(k, k)`` are equivalent.\n        stride (int or pair of ints): Stride of filter applications.\n            ``stride=s`` and ``stride=(s, s)`` are equivalent.\n        pad (int or pair of ints): Spatial padding width for input arrays.\n            ``pad=p`` and ``pad=(p, p)`` are equivalent.\n        nobias (bool): If ``True``, then this function does not use the bias\n            term.\n        outsize (tuple): Expected output size of deconvolutional operation.\n            It should be pair of height and width :math:`(out_H, out_W)`.\n            Default value is ``None`` and the outsize is estimated by\n            input size, stride and pad.\n        initialW (:ref:`initializer <initializer>`): Initializer to\n            initialize the weight. When it is :class:`numpy.ndarray`,\n            its ``ndim`` should be 4.\n        initial_bias (:ref:`initializer <initializer>`): Initializer to\n            initialize the bias. If ``None``, the bias will be initialized to\n            zero. When it is :class:`numpy.ndarray`, its ``ndim`` should be 1.\n        groups (int): The number of groups to use grouped deconvolution. The\n            default is one, where grouped deconvolution is not used.\n\n    The filter weight has four dimensions :math:`(c_I, c_O, k_H, k_W)`\n    which indicate the number of input channels, output channels,\n    height and width of the kernels, respectively.\n    The filter weight is initialized with i.i.d. Gaussian random samples, each\n    of which has zero mean and deviation :math:`\\\\sqrt{1/(c_I k_H k_W)}` by\n    default.\n\n    The bias vector is of size :math:`c_O`.\n    Its elements are initialized by ``bias`` argument.\n    If ``nobias`` argument is set to True, then this function does not hold\n    the bias parameter.\n\n    The output of this function can be non-deterministic when it uses cuDNN.\n    If ``chainer.configuration.config.cudnn_deterministic`` is ``True`` and\n    cuDNN version is >= v3, it forces cuDNN to use a deterministic algorithm.\n\n    .. seealso::\n       See :func:`chainer.functions.deconvolution_2d` for the definition of\n       two-dimensional convolution.\n\n    .. seealso::\n        See :func:`chainer.links.Convolution2D` for the examples of ways to\n        give arguments to this link.\n\n    .. admonition:: Example\n\n        There are several ways to make a Deconvolution2D link.\n\n        Let an input vector ``x`` be:\n\n        >>> x = np.arange(1 * 3 * 10 * 10, dtype=np.float32).reshape(1, 3, 10, 10)\n\n        1. Give the first three arguments explicitly:\n\n            In this case, all the other arguments are set to the default\n            values.\n\n            >>> l = L.Deconvolution2D(3, 7, 4)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 13, 13)\n\n        2. Omit ``in_channels`` or fill it with ``None``:\n\n            The below two cases are the same.\n\n            >>> l = L.Deconvolution2D(7, 4)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 13, 13)\n\n            >>> l = L.Deconvolution2D(None, 7, 4)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 13, 13)\n\n            When you omit the first argument, you need to specify the other\n            subsequent arguments from ``stride`` as keyword arguments. So the\n            below two cases are the same.\n\n            >>> l = L.Deconvolution2D(None, 7, 4, 2, 1)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 20, 20)\n\n            >>> l = L.Deconvolution2D(7, 4, stride=2, pad=1)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 20, 20)\n\n    \"\"\"  # NOQA\n\n    def __init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0,\n                 nobias=False, outsize=None, initialW=None, initial_bias=None,\n                 **kwargs):\n        super(Deconvolution2D, self).__init__()\n\n        groups, = argument.parse_kwargs(\n            kwargs, ('groups', 1),\n            deterministic=\"deterministic argument is not supported anymore. \"\n            \"Use chainer.using_config('cudnn_deterministic', value) \"\n            \"context where value is either `True` or `False`.\")\n\n        if ksize is None:\n            out_channels, ksize, in_channels = in_channels, out_channels, None\n\n        self.ksize = ksize\n        self.stride = _pair(stride)\n        self.pad = _pair(pad)\n        self.outsize = (None, None) if outsize is None else outsize\n        self.out_channels = out_channels\n        self.groups = int(groups)\n\n        with self.init_scope():\n            W_initializer = initializers._get_initializer(initialW)\n            self.W = variable.Parameter(W_initializer)\n            if in_channels is not None:\n                self._initialize_params(in_channels)\n\n            if nobias:\n                self.b = None\n            else:\n                if isinstance(initial_bias, (numpy.ndarray, cuda.ndarray)):\n                    assert initial_bias.shape == (out_channels,)\n                if initial_bias is None:\n                    initial_bias = 0\n                bias_initializer = initializers._get_initializer(initial_bias)\n                self.b = variable.Parameter(bias_initializer, out_channels)\n\n    def _initialize_params(self, in_channels):\n        kh, kw = _pair(self.ksize)\n        if self.out_channels % self.groups != 0:\n            raise ValueError('the number of output channels must be'\n                             'divisible by the number of groups')\n        if in_channels % self.groups != 0:\n            raise ValueError('the number of input channels must be'\n                             'divisible by the number of groups')\n        W_shape = (in_channels, int(self.out_channels / self.groups), kh, kw)\n        self.W.initialize(W_shape)\n\n    def forward(self, x):\n        if self.W.array is None:\n            self._initialize_params(x.shape[1])\n        return deconvolution_2d.deconvolution_2d(\n            x, self.W, self.b, self.stride, self.pad, self.outsize,\n            groups=self.groups)\n\n\ndef _pair(x):\n    if hasattr(x, '__getitem__'):\n        return x\n    return x, x\n", "path": "chainer/links/connection/deconvolution_2d.py"}], "after_files": [{"content": "import numpy\n\nfrom chainer.backends import cuda\nfrom chainer.functions.connection import deconvolution_2d\nfrom chainer import initializers\nfrom chainer import link\nfrom chainer.utils import argument\nfrom chainer import variable\n\n\nclass Deconvolution2D(link.Link):\n\n    \"\"\"__init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, outsize=None, initialW=None, initial_bias=None, *, dilate=1, groups=1)\n\n    Two dimensional deconvolution function.\n\n    This link wraps the :func:`~chainer.functions.deconvolution_2d` function\n    and holds the filter weight and bias vector as parameters.\n\n    Deconvolution links can use a feature of cuDNN called autotuning, which\n    selects the most efficient CNN algorithm for images of fixed-size, \n    can provide a significant performance boost for fixed neural nets.\n    To enable, set `chainer.using_config('autotune', True)`\n\n    Args:\n        in_channels (int or None): Number of channels of input arrays.\n            If ``None``, parameter initialization will be deferred until the\n            first forward data pass at which time the size will be determined.\n        out_channels (int): Number of channels of output arrays.\n        ksize (int or pair of ints): Size of filters (a.k.a. kernels).\n            ``ksize=k`` and ``ksize=(k, k)`` are equivalent.\n        stride (int or pair of ints): Stride of filter applications.\n            ``stride=s`` and ``stride=(s, s)`` are equivalent.\n        pad (int or pair of ints): Spatial padding width for input arrays.\n            ``pad=p`` and ``pad=(p, p)`` are equivalent.\n        nobias (bool): If ``True``, then this function does not use the bias\n            term.\n        outsize (tuple): Expected output size of deconvolutional operation.\n            It should be pair of height and width :math:`(out_H, out_W)`.\n            Default value is ``None`` and the outsize is estimated by\n            input size, stride and pad.\n        initialW (:ref:`initializer <initializer>`): Initializer to\n            initialize the weight. When it is :class:`numpy.ndarray`,\n            its ``ndim`` should be 4.\n        initial_bias (:ref:`initializer <initializer>`): Initializer to\n            initialize the bias. If ``None``, the bias will be initialized to\n            zero. When it is :class:`numpy.ndarray`, its ``ndim`` should be 1.\n        dilate (:class:`int` or :class:`tuple` of :class:`int` s):\n            Dilation factor of filter applications.\n            ``dilate=d`` and ``dilate=(d, d)`` are equivalent.\n        groups (int): The number of groups to use grouped deconvolution. The\n            default is one, where grouped deconvolution is not used.\n\n    The filter weight has four dimensions :math:`(c_I, c_O, k_H, k_W)`\n    which indicate the number of input channels, output channels,\n    height and width of the kernels, respectively.\n    The filter weight is initialized with i.i.d. Gaussian random samples, each\n    of which has zero mean and deviation :math:`\\\\sqrt{1/(c_I k_H k_W)}` by\n    default.\n\n    The bias vector is of size :math:`c_O`.\n    Its elements are initialized by ``bias`` argument.\n    If ``nobias`` argument is set to True, then this function does not hold\n    the bias parameter.\n\n    The output of this function can be non-deterministic when it uses cuDNN.\n    If ``chainer.configuration.config.cudnn_deterministic`` is ``True`` and\n    cuDNN version is >= v3, it forces cuDNN to use a deterministic algorithm.\n\n    .. seealso::\n       See :func:`chainer.functions.deconvolution_2d` for the definition of\n       two-dimensional convolution.\n\n    .. seealso::\n        See :func:`chainer.links.Convolution2D` for the examples of ways to\n        give arguments to this link.\n\n    .. admonition:: Example\n\n        There are several ways to make a Deconvolution2D link.\n\n        Let an input vector ``x`` be:\n\n        >>> x = np.arange(1 * 3 * 10 * 10, dtype=np.float32).reshape(1, 3, 10, 10)\n\n        1. Give the first three arguments explicitly:\n\n            In this case, all the other arguments are set to the default\n            values.\n\n            >>> l = L.Deconvolution2D(3, 7, 4)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 13, 13)\n\n        2. Omit ``in_channels`` or fill it with ``None``:\n\n            The below two cases are the same.\n\n            >>> l = L.Deconvolution2D(7, 4)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 13, 13)\n\n            >>> l = L.Deconvolution2D(None, 7, 4)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 13, 13)\n\n            When you omit the first argument, you need to specify the other\n            subsequent arguments from ``stride`` as keyword arguments. So the\n            below two cases are the same.\n\n            >>> l = L.Deconvolution2D(None, 7, 4, 2, 1)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 20, 20)\n\n            >>> l = L.Deconvolution2D(7, 4, stride=2, pad=1)\n            >>> y = l(x)\n            >>> y.shape\n            (1, 7, 20, 20)\n\n    \"\"\"  # NOQA\n\n    def __init__(self, in_channels, out_channels, ksize=None, stride=1, pad=0,\n                 nobias=False, outsize=None, initialW=None, initial_bias=None,\n                 **kwargs):\n        super(Deconvolution2D, self).__init__()\n\n        dilate, groups, = argument.parse_kwargs(\n            kwargs, ('dilate', 1), ('groups', 1),\n            deterministic=\"deterministic argument is not supported anymore. \"\n            \"Use chainer.using_config('cudnn_deterministic', value) \"\n            \"context where value is either `True` or `False`.\")\n\n        if ksize is None:\n            out_channels, ksize, in_channels = in_channels, out_channels, None\n\n        self.ksize = ksize\n        self.stride = _pair(stride)\n        self.pad = _pair(pad)\n        self.dilate = _pair(dilate)\n        self.outsize = (None, None) if outsize is None else outsize\n        self.out_channels = out_channels\n        self.groups = int(groups)\n\n        with self.init_scope():\n            W_initializer = initializers._get_initializer(initialW)\n            self.W = variable.Parameter(W_initializer)\n            if in_channels is not None:\n                self._initialize_params(in_channels)\n\n            if nobias:\n                self.b = None\n            else:\n                if isinstance(initial_bias, (numpy.ndarray, cuda.ndarray)):\n                    assert initial_bias.shape == (out_channels,)\n                if initial_bias is None:\n                    initial_bias = 0\n                bias_initializer = initializers._get_initializer(initial_bias)\n                self.b = variable.Parameter(bias_initializer, out_channels)\n\n    def _initialize_params(self, in_channels):\n        kh, kw = _pair(self.ksize)\n        if self.out_channels % self.groups != 0:\n            raise ValueError('the number of output channels must be'\n                             'divisible by the number of groups')\n        if in_channels % self.groups != 0:\n            raise ValueError('the number of input channels must be'\n                             'divisible by the number of groups')\n        W_shape = (in_channels, int(self.out_channels / self.groups), kh, kw)\n        self.W.initialize(W_shape)\n\n    def forward(self, x):\n        if self.W.array is None:\n            self._initialize_params(x.shape[1])\n        return deconvolution_2d.deconvolution_2d(\n            x, self.W, self.b, self.stride, self.pad, self.outsize,\n            dilate=self.dilate, groups=self.groups)\n\n\ndef _pair(x):\n    if hasattr(x, '__getitem__'):\n        return x\n    return x, x\n", "path": "chainer/links/connection/deconvolution_2d.py"}]}