sets up dummy convolutional forward pass and uses its grad as deconv currently only tested/working with same padding
(X, w, subsample=(1, 1), border_mode=(0, 0), conv_mode='conv')
| 83 | return X |
| 84 | |
| 85 | def deconv(X, w, subsample=(1, 1), border_mode=(0, 0), conv_mode='conv'): |
| 86 | """ |
| 87 | sets up dummy convolutional forward pass and uses its grad as deconv |
| 88 | currently only tested/working with same padding |
| 89 | """ |
| 90 | img = gpu_contiguous(X) |
| 91 | kerns = gpu_contiguous(w) |
| 92 | desc = GpuDnnConvDesc(border_mode=border_mode, subsample=subsample, |
| 93 | conv_mode=conv_mode)(gpu_alloc_empty(img.shape[0], kerns.shape[1], img.shape[2]*subsample[0], img.shape[3]*subsample[1]).shape, kerns.shape) |
| 94 | out = gpu_alloc_empty(img.shape[0], kerns.shape[1], img.shape[2]*subsample[0], img.shape[3]*subsample[1]) |
| 95 | d_img = GpuDnnConvGradI()(kerns, img, out, desc) |
| 96 | return d_img |