padding.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. from .module import Module
  2. from .utils import _pair, _quadruple, _ntuple
  3. from .. import functional as F
  4. from torch import Tensor
  5. from ..common_types import _size_2_t, _size_4_t, _size_6_t
  6. from typing import Sequence, Tuple
  7. # TODO: grad_output size asserts in THNN
  8. class _ConstantPadNd(Module):
  9. __constants__ = ['padding', 'value']
  10. value: float
  11. padding: Sequence[int]
  12. def __init__(self, value: float) -> None:
  13. super(_ConstantPadNd, self).__init__()
  14. self.value = value
  15. def forward(self, input: Tensor) -> Tensor:
  16. return F.pad(input, self.padding, 'constant', self.value)
  17. def extra_repr(self) -> str:
  18. return 'padding={}, value={}'.format(self.padding, self.value)
  19. class ConstantPad1d(_ConstantPadNd):
  20. r"""Pads the input tensor boundaries with a constant value.
  21. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  22. Args:
  23. padding (int, tuple): the size of the padding. If is `int`, uses the same
  24. padding in both boundaries. If a 2-`tuple`, uses
  25. (:math:`\text{padding\_left}`, :math:`\text{padding\_right}`)
  26. Shape:
  27. - Input: :math:`(C, W_{in})` or :math:`(N, C, W_{in})`.
  28. - Output: :math:`(C, W_{out})` or :math:`(N, C, W_{out})`, where
  29. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  30. Examples::
  31. >>> m = nn.ConstantPad1d(2, 3.5)
  32. >>> input = torch.randn(1, 2, 4)
  33. >>> input
  34. tensor([[[-1.0491, -0.7152, -0.0749, 0.8530],
  35. [-1.3287, 1.8966, 0.1466, -0.2771]]])
  36. >>> m(input)
  37. tensor([[[ 3.5000, 3.5000, -1.0491, -0.7152, -0.0749, 0.8530, 3.5000,
  38. 3.5000],
  39. [ 3.5000, 3.5000, -1.3287, 1.8966, 0.1466, -0.2771, 3.5000,
  40. 3.5000]]])
  41. >>> m = nn.ConstantPad1d(2, 3.5)
  42. >>> input = torch.randn(1, 2, 3)
  43. >>> input
  44. tensor([[[ 1.6616, 1.4523, -1.1255],
  45. [-3.6372, 0.1182, -1.8652]]])
  46. >>> m(input)
  47. tensor([[[ 3.5000, 3.5000, 1.6616, 1.4523, -1.1255, 3.5000, 3.5000],
  48. [ 3.5000, 3.5000, -3.6372, 0.1182, -1.8652, 3.5000, 3.5000]]])
  49. >>> # using different paddings for different sides
  50. >>> m = nn.ConstantPad1d((3, 1), 3.5)
  51. >>> m(input)
  52. tensor([[[ 3.5000, 3.5000, 3.5000, 1.6616, 1.4523, -1.1255, 3.5000],
  53. [ 3.5000, 3.5000, 3.5000, -3.6372, 0.1182, -1.8652, 3.5000]]])
  54. """
  55. padding: Tuple[int, int]
  56. def __init__(self, padding: _size_2_t, value: float):
  57. super(ConstantPad1d, self).__init__(value)
  58. self.padding = _pair(padding)
  59. class ConstantPad2d(_ConstantPadNd):
  60. r"""Pads the input tensor boundaries with a constant value.
  61. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  62. Args:
  63. padding (int, tuple): the size of the padding. If is `int`, uses the same
  64. padding in all boundaries. If a 4-`tuple`, uses (:math:`\text{padding\_left}`,
  65. :math:`\text{padding\_right}`, :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`)
  66. Shape:
  67. - Input: :math:`(N, C, H_{in}, W_{in})` or :math:`(C, H_{in}, W_{in})`.
  68. - Output: :math:`(N, C, H_{out}, W_{out})` or :math:`(C, H_{out}, W_{out})`, where
  69. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  70. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  71. Examples::
  72. >>> m = nn.ConstantPad2d(2, 3.5)
  73. >>> input = torch.randn(1, 2, 2)
  74. >>> input
  75. tensor([[[ 1.6585, 0.4320],
  76. [-0.8701, -0.4649]]])
  77. >>> m(input)
  78. tensor([[[ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000, 3.5000],
  79. [ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000, 3.5000],
  80. [ 3.5000, 3.5000, 1.6585, 0.4320, 3.5000, 3.5000],
  81. [ 3.5000, 3.5000, -0.8701, -0.4649, 3.5000, 3.5000],
  82. [ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000, 3.5000],
  83. [ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000, 3.5000]]])
  84. >>> # using different paddings for different sides
  85. >>> m = nn.ConstantPad2d((3, 0, 2, 1), 3.5)
  86. >>> m(input)
  87. tensor([[[ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000],
  88. [ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000],
  89. [ 3.5000, 3.5000, 3.5000, 1.6585, 0.4320],
  90. [ 3.5000, 3.5000, 3.5000, -0.8701, -0.4649],
  91. [ 3.5000, 3.5000, 3.5000, 3.5000, 3.5000]]])
  92. """
  93. __constants__ = ['padding', 'value']
  94. padding: Tuple[int, int, int, int]
  95. def __init__(self, padding: _size_4_t, value: float) -> None:
  96. super(ConstantPad2d, self).__init__(value)
  97. self.padding = _quadruple(padding)
  98. class ConstantPad3d(_ConstantPadNd):
  99. r"""Pads the input tensor boundaries with a constant value.
  100. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  101. Args:
  102. padding (int, tuple): the size of the padding. If is `int`, uses the same
  103. padding in all boundaries. If a 6-`tuple`, uses
  104. (:math:`\text{padding\_left}`, :math:`\text{padding\_right}`,
  105. :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`,
  106. :math:`\text{padding\_front}`, :math:`\text{padding\_back}`)
  107. Shape:
  108. - Input: :math:`(N, C, D_{in}, H_{in}, W_{in})` or :math:`(C, D_{in}, H_{in}, W_{in})`.
  109. - Output: :math:`(N, C, D_{out}, H_{out}, W_{out})` or
  110. :math:`(C, D_{out}, H_{out}, W_{out})`, where
  111. :math:`D_{out} = D_{in} + \text{padding\_front} + \text{padding\_back}`
  112. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  113. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  114. Examples::
  115. >>> m = nn.ConstantPad3d(3, 3.5)
  116. >>> input = torch.randn(16, 3, 10, 20, 30)
  117. >>> output = m(input)
  118. >>> # using different paddings for different sides
  119. >>> m = nn.ConstantPad3d((3, 3, 6, 6, 0, 1), 3.5)
  120. >>> output = m(input)
  121. """
  122. padding: Tuple[int, int, int, int, int, int]
  123. def __init__(self, padding: _size_6_t, value: float) -> None:
  124. super(ConstantPad3d, self).__init__(value)
  125. self.padding = _ntuple(6)(padding)
  126. class _ReflectionPadNd(Module):
  127. __constants__ = ['padding']
  128. padding: Sequence[int]
  129. def forward(self, input: Tensor) -> Tensor:
  130. return F.pad(input, self.padding, 'reflect')
  131. def extra_repr(self) -> str:
  132. return '{}'.format(self.padding)
  133. class ReflectionPad1d(_ReflectionPadNd):
  134. r"""Pads the input tensor using the reflection of the input boundary.
  135. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  136. Args:
  137. padding (int, tuple): the size of the padding. If is `int`, uses the same
  138. padding in all boundaries. If a 2-`tuple`, uses
  139. (:math:`\text{padding\_left}`, :math:`\text{padding\_right}`)
  140. Shape:
  141. - Input: :math:`(C, W_{in})` or :math:`(N, C, W_{in})`.
  142. - Output: :math:`(C, W_{out})` or :math:`(N, C, W_{out})`, where
  143. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  144. Examples::
  145. >>> m = nn.ReflectionPad1d(2)
  146. >>> input = torch.arange(8, dtype=torch.float).reshape(1, 2, 4)
  147. >>> input
  148. tensor([[[0., 1., 2., 3.],
  149. [4., 5., 6., 7.]]])
  150. >>> m(input)
  151. tensor([[[2., 1., 0., 1., 2., 3., 2., 1.],
  152. [6., 5., 4., 5., 6., 7., 6., 5.]]])
  153. >>> # using different paddings for different sides
  154. >>> m = nn.ReflectionPad1d((3, 1))
  155. >>> m(input)
  156. tensor([[[3., 2., 1., 0., 1., 2., 3., 2.],
  157. [7., 6., 5., 4., 5., 6., 7., 6.]]])
  158. """
  159. padding: Tuple[int, int]
  160. def __init__(self, padding: _size_2_t) -> None:
  161. super(ReflectionPad1d, self).__init__()
  162. self.padding = _pair(padding)
  163. class ReflectionPad2d(_ReflectionPadNd):
  164. r"""Pads the input tensor using the reflection of the input boundary.
  165. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  166. Args:
  167. padding (int, tuple): the size of the padding. If is `int`, uses the same
  168. padding in all boundaries. If a 4-`tuple`, uses (:math:`\text{padding\_left}`,
  169. :math:`\text{padding\_right}`, :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`)
  170. Shape:
  171. - Input: :math:`(N, C, H_{in}, W_{in})` or :math:`(C, H_{in}, W_{in})`.
  172. - Output: :math:`(N, C, H_{out}, W_{out})` or :math:`(C, H_{out}, W_{out})` where
  173. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  174. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  175. Examples::
  176. >>> m = nn.ReflectionPad2d(2)
  177. >>> input = torch.arange(9, dtype=torch.float).reshape(1, 1, 3, 3)
  178. >>> input
  179. tensor([[[[0., 1., 2.],
  180. [3., 4., 5.],
  181. [6., 7., 8.]]]])
  182. >>> m(input)
  183. tensor([[[[8., 7., 6., 7., 8., 7., 6.],
  184. [5., 4., 3., 4., 5., 4., 3.],
  185. [2., 1., 0., 1., 2., 1., 0.],
  186. [5., 4., 3., 4., 5., 4., 3.],
  187. [8., 7., 6., 7., 8., 7., 6.],
  188. [5., 4., 3., 4., 5., 4., 3.],
  189. [2., 1., 0., 1., 2., 1., 0.]]]])
  190. >>> # using different paddings for different sides
  191. >>> m = nn.ReflectionPad2d((1, 1, 2, 0))
  192. >>> m(input)
  193. tensor([[[[7., 6., 7., 8., 7.],
  194. [4., 3., 4., 5., 4.],
  195. [1., 0., 1., 2., 1.],
  196. [4., 3., 4., 5., 4.],
  197. [7., 6., 7., 8., 7.]]]])
  198. """
  199. padding: Tuple[int, int, int, int]
  200. def __init__(self, padding: _size_4_t) -> None:
  201. super(ReflectionPad2d, self).__init__()
  202. self.padding = _quadruple(padding)
  203. class ReflectionPad3d(_ReflectionPadNd):
  204. r"""Pads the input tensor using the reflection of the input boundary.
  205. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  206. Args:
  207. padding (int, tuple): the size of the padding. If is `int`, uses the same
  208. padding in all boundaries. If a 6-`tuple`, uses
  209. (:math:`\text{padding\_left}`, :math:`\text{padding\_right}`,
  210. :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`,
  211. :math:`\text{padding\_front}`, :math:`\text{padding\_back}`)
  212. Shape:
  213. - Input: :math:`(N, C, D_{in}, H_{in}, W_{in})` or :math:`(C, D_{in}, H_{in}, W_{in})`.
  214. - Output: :math:`(N, C, D_{out}, H_{out}, W_{out})` or :math:`(C, D_{out}, H_{out}, W_{out})`,
  215. where
  216. :math:`D_{out} = D_{in} + \text{padding\_front} + \text{padding\_back}`
  217. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  218. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  219. Examples::
  220. >>> m = nn.ReflectionPad3d(1)
  221. >>> input = torch.arange(8, dtype=torch.float).reshape(1, 1, 2, 2, 2)
  222. >>> m(input)
  223. tensor([[[[[7., 6., 7., 6.],
  224. [5., 4., 5., 4.],
  225. [7., 6., 7., 6.],
  226. [5., 4., 5., 4.]],
  227. [[3., 2., 3., 2.],
  228. [1., 0., 1., 0.],
  229. [3., 2., 3., 2.],
  230. [1., 0., 1., 0.]],
  231. [[7., 6., 7., 6.],
  232. [5., 4., 5., 4.],
  233. [7., 6., 7., 6.],
  234. [5., 4., 5., 4.]],
  235. [[3., 2., 3., 2.],
  236. [1., 0., 1., 0.],
  237. [3., 2., 3., 2.],
  238. [1., 0., 1., 0.]]]]])
  239. """
  240. padding: Tuple[int, int, int, int, int, int]
  241. def __init__(self, padding: _size_6_t) -> None:
  242. super(ReflectionPad3d, self).__init__()
  243. self.padding = _ntuple(6)(padding)
  244. class _ReplicationPadNd(Module):
  245. __constants__ = ['padding']
  246. padding: Sequence[int]
  247. def forward(self, input: Tensor) -> Tensor:
  248. return F.pad(input, self.padding, 'replicate')
  249. def extra_repr(self) -> str:
  250. return '{}'.format(self.padding)
  251. class ReplicationPad1d(_ReplicationPadNd):
  252. r"""Pads the input tensor using replication of the input boundary.
  253. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  254. Args:
  255. padding (int, tuple): the size of the padding. If is `int`, uses the same
  256. padding in all boundaries. If a 2-`tuple`, uses
  257. (:math:`\text{padding\_left}`, :math:`\text{padding\_right}`)
  258. Shape:
  259. - Input: :math:`(C, W_{in})` or :math:`(N, C, W_{in})`.
  260. - Output: :math:`(C, W_{out})` or :math:`(N, C, W_{out})`, where
  261. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  262. Examples::
  263. >>> m = nn.ReplicationPad1d(2)
  264. >>> input = torch.arange(8, dtype=torch.float).reshape(1, 2, 4)
  265. >>> input
  266. tensor([[[0., 1., 2., 3.],
  267. [4., 5., 6., 7.]]])
  268. >>> m(input)
  269. tensor([[[0., 0., 0., 1., 2., 3., 3., 3.],
  270. [4., 4., 4., 5., 6., 7., 7., 7.]]])
  271. >>> # using different paddings for different sides
  272. >>> m = nn.ReplicationPad1d((3, 1))
  273. >>> m(input)
  274. tensor([[[0., 0., 0., 0., 1., 2., 3., 3.],
  275. [4., 4., 4., 4., 5., 6., 7., 7.]]])
  276. """
  277. padding: Tuple[int, int]
  278. def __init__(self, padding: _size_2_t) -> None:
  279. super(ReplicationPad1d, self).__init__()
  280. self.padding = _pair(padding)
  281. class ReplicationPad2d(_ReplicationPadNd):
  282. r"""Pads the input tensor using replication of the input boundary.
  283. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  284. Args:
  285. padding (int, tuple): the size of the padding. If is `int`, uses the same
  286. padding in all boundaries. If a 4-`tuple`, uses (:math:`\text{padding\_left}`,
  287. :math:`\text{padding\_right}`, :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`)
  288. Shape:
  289. - Input: :math:`(N, C, H_{in}, W_{in})` or :math:`(C, H_{in}, W_{in})`.
  290. - Output: :math:`(N, C, H_{out}, W_{out})` or :math:`(C, H_{out}, W_{out})`, where
  291. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  292. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  293. Examples::
  294. >>> m = nn.ReplicationPad2d(2)
  295. >>> input = torch.arange(9, dtype=torch.float).reshape(1, 1, 3, 3)
  296. >>> input
  297. tensor([[[[0., 1., 2.],
  298. [3., 4., 5.],
  299. [6., 7., 8.]]]])
  300. >>> m(input)
  301. tensor([[[[0., 0., 0., 1., 2., 2., 2.],
  302. [0., 0., 0., 1., 2., 2., 2.],
  303. [0., 0., 0., 1., 2., 2., 2.],
  304. [3., 3., 3., 4., 5., 5., 5.],
  305. [6., 6., 6., 7., 8., 8., 8.],
  306. [6., 6., 6., 7., 8., 8., 8.],
  307. [6., 6., 6., 7., 8., 8., 8.]]]])
  308. >>> # using different paddings for different sides
  309. >>> m = nn.ReplicationPad2d((1, 1, 2, 0))
  310. >>> m(input)
  311. tensor([[[[0., 0., 1., 2., 2.],
  312. [0., 0., 1., 2., 2.],
  313. [0., 0., 1., 2., 2.],
  314. [3., 3., 4., 5., 5.],
  315. [6., 6., 7., 8., 8.]]]])
  316. """
  317. padding: Tuple[int, int, int, int]
  318. def __init__(self, padding: _size_4_t) -> None:
  319. super(ReplicationPad2d, self).__init__()
  320. self.padding = _quadruple(padding)
  321. class ReplicationPad3d(_ReplicationPadNd):
  322. r"""Pads the input tensor using replication of the input boundary.
  323. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  324. Args:
  325. padding (int, tuple): the size of the padding. If is `int`, uses the same
  326. padding in all boundaries. If a 6-`tuple`, uses
  327. (:math:`\text{padding\_left}`, :math:`\text{padding\_right}`,
  328. :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`,
  329. :math:`\text{padding\_front}`, :math:`\text{padding\_back}`)
  330. Shape:
  331. - Input: :math:`(N, C, D_{in}, H_{in}, W_{in})` or :math:`(C, D_{in}, H_{in}, W_{in})`.
  332. - Output: :math:`(N, C, D_{out}, H_{out}, W_{out})` or :math:`(C, D_{out}, H_{out}, W_{out})`,
  333. where
  334. :math:`D_{out} = D_{in} + \text{padding\_front} + \text{padding\_back}`
  335. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  336. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  337. Examples::
  338. >>> m = nn.ReplicationPad3d(3)
  339. >>> input = torch.randn(16, 3, 8, 320, 480)
  340. >>> output = m(input)
  341. >>> # using different paddings for different sides
  342. >>> m = nn.ReplicationPad3d((3, 3, 6, 6, 1, 1))
  343. >>> output = m(input)
  344. """
  345. padding: Tuple[int, int, int, int, int, int]
  346. def __init__(self, padding: _size_6_t) -> None:
  347. super(ReplicationPad3d, self).__init__()
  348. self.padding = _ntuple(6)(padding)
  349. class ZeroPad2d(ConstantPad2d):
  350. r"""Pads the input tensor boundaries with zero.
  351. For `N`-dimensional padding, use :func:`torch.nn.functional.pad()`.
  352. Args:
  353. padding (int, tuple): the size of the padding. If is `int`, uses the same
  354. padding in all boundaries. If a 4-`tuple`, uses (:math:`\text{padding\_left}`,
  355. :math:`\text{padding\_right}`, :math:`\text{padding\_top}`, :math:`\text{padding\_bottom}`)
  356. Shape:
  357. - Input: :math:`(N, C, H_{in}, W_{in})` or :math:`(C, H_{in}, W_{in})`.
  358. - Output: :math:`(N, C, H_{out}, W_{out})` or :math:`(C, H_{out}, W_{out})`, where
  359. :math:`H_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}`
  360. :math:`W_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}`
  361. Examples::
  362. >>> m = nn.ZeroPad2d(2)
  363. >>> input = torch.randn(1, 1, 3, 3)
  364. >>> input
  365. tensor([[[[-0.1678, -0.4418, 1.9466],
  366. [ 0.9604, -0.4219, -0.5241],
  367. [-0.9162, -0.5436, -0.6446]]]])
  368. >>> m(input)
  369. tensor([[[[ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
  370. [ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
  371. [ 0.0000, 0.0000, -0.1678, -0.4418, 1.9466, 0.0000, 0.0000],
  372. [ 0.0000, 0.0000, 0.9604, -0.4219, -0.5241, 0.0000, 0.0000],
  373. [ 0.0000, 0.0000, -0.9162, -0.5436, -0.6446, 0.0000, 0.0000],
  374. [ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
  375. [ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000]]]])
  376. >>> # using different paddings for different sides
  377. >>> m = nn.ZeroPad2d((1, 1, 2, 0))
  378. >>> m(input)
  379. tensor([[[[ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
  380. [ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
  381. [ 0.0000, -0.1678, -0.4418, 1.9466, 0.0000],
  382. [ 0.0000, 0.9604, -0.4219, -0.5241, 0.0000],
  383. [ 0.0000, -0.9162, -0.5436, -0.6446, 0.0000]]]])
  384. """
  385. padding: Tuple[int, int, int, int]
  386. def __init__(self, padding: _size_4_t) -> None:
  387. super(ZeroPad2d, self).__init__(padding, 0.)
  388. def extra_repr(self) -> str:
  389. return '{}'.format(self.padding)