Skip to content

Deconv1D

Warning

Documentation for the module is under development.

Description

Info

Parent class: DeconvND

Derived classes: -

This module performs the operation of 1-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 -
stride int Convolution stride 1
pad int Map padding 0
dilation int 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 Deconv1D

Info

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

batchsize, inmaps, l = 1, 2, 5
outsize = 2

Synthetic tensor:

data = gpuarray.to_gpu(np.arange(batchsize * inmaps * l).reshape((batchsize, inmaps, l)).astype(np.float32))
deconv = Deconv1D(inmaps=inmaps, outmaps=outsize, size=2, useBias=False)
print(deconv(data))


Size parameter


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

Pad parameter


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

Stride parameter


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

Dilation parameter


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

Groups parameter


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