Skip to content

Deconv2D

Warning

Documentation for the module is under development.

Description

Info

Parent class: DeconvND

Derived classes: -

This module performs the operation of 2-dimensional transposed convolution. For more detailed theoretical information about the transposed convolution operation, see DeconvND.

Initializing

def __init__(self, inmaps, outmaps, size, stride=1, pad=0, dilation=1, wscale=1.0, useBias=True, name=None,
                 initscheme=None, empty=False, groups=1):

Parameters

Parameter Allowed types Description Default
inmaps int Number of maps in the input tensor -
outmaps int Number of maps in the output tensor -
size int Convolution kernel size (the kernel is always equilateral) -
stride Union[int, tuple] Convolution stride 1
pad Union[int, tuple] Map padding 0
dilation Union[int, tuple] Convolution window dilation 1
wscale float Random layer weights variance 1.0
useBias bool Whether to use the bias vector True
initscheme Union[tuple, str] Specifies the layer weights initialization scheme (see createTensorWithScheme) None -> ("xavier_uniform", "in")
name str Layer name None
empty bool Whether to initialize the matrix of weights and biases False
groups int Number of groups the maps are split into for separate processing 1

Explanations

-

Examples


Basic deconvolution example


Necessary imports

import numpy as np
from PuzzleLib.Backend import gpuarray
from PuzzleLib.Modules import Deconv2D
from PuzzleLib.Variable import Variable

Info

gpuarray is required to properly place the tensor in the GPU.

batchsize, inmaps, h, w = 1, 2, 5, 5
outsize = 2

Synthetic tensor:

data = gpuarray.to_gpu(np.arange(batchsize * inmaps * h * w).reshape((batchsize, inmaps, h, w)).astype(np.float32))

deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, useBias=False)
print(deconv(data))

Size parameter


deconv = Deconv2D(inmaps=inmaps,outmaps=outsize, size=3, useBias=False)
print(deconv(data))

Pad parameter


deconv = Deconv2D(inmaps=inmaps,outmaps=outsize, size=3, pad=1, useBias=False)
print(deconv(data))

Stride parameter


deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, stride=2, useBias=False)
print(deconv(data))
deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, stride=2, pad=3, useBias=False)
print(deconv(data))
deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, stride=(2, 4), pad=3, useBias=False)
print(deconv(data))

Параметр dilation


deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, stride=1, pad=0, dilation=2, useBias=False)
print(deconv(data))
deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, stride=1, pad=0, dilation=(3, 1), useBias=False)
print(deconv(data))

Groups parameter


deconv = Deconv2D(inmaps=inmaps, outmaps=outsize, size=2, groups=2, useBias=False)
print(deconv(data))