1D dilation using numpy Parameters ---------- x : numpy.ndarray Array to dilate with shape [batch, in_channel, in_width] dilation : int dilation rate of output Returns ------- out : numpy.ndarray Dilated output with shape [batch, in_channel, (in
(x, dilation)
| 23 | |
| 24 | |
| 25 | def dilate_np(x, dilation): |
| 26 | """1D dilation using numpy |
| 27 | |
| 28 | Parameters |
| 29 | ---------- |
| 30 | x : numpy.ndarray |
| 31 | Array to dilate with shape [batch, in_channel, in_width] |
| 32 | |
| 33 | dilation : int |
| 34 | dilation rate of output |
| 35 | |
| 36 | Returns |
| 37 | ------- |
| 38 | out : numpy.ndarray |
| 39 | Dilated output with shape [batch, in_channel, (in_width - 1) * dilation + 1] |
| 40 | """ |
| 41 | irange = range(len(x) - 1) |
| 42 | for d in range(dilation - 1): |
| 43 | indices = [(d + 1) * (i + 1) for i in irange] |
| 44 | x = np.insert(x, indices, 0) |
| 45 | return x |
| 46 | |
| 47 | |
| 48 | def group_conv1d_ncw_python(a_np, w_np, stride, padding, dilation, groups): |
no outgoing calls
no test coverage detected
searching dependent graphs…