tltorch.factorized_conv.TTConv

class tltorch.factorized_conv.TTConv(*args, **kwargs)[source]

Create a convolution of arbitrary order with a Tucker kernel.

Parameters:
in_channelsint
out_channelsint
kernel_sizeint or int list

if int, order MUST be specified if int list, then the conv will use order = len(kernel_size)

rankint

rank of the factorized kernel

orderint, optional if kernel_size is a list

see kernel_size

implementation = {‘factorized’, ‘reconstructed’}

strategy to use for the forward pass - factorized : the TT conv is expressed as a series of 1D convolutions - reconstructed : full kernel is reconstructed from the decomposition. the reconstruction is used to perform a regular forward pass

strideint, default is 1
paddingint, default is 0
dilationint, default is 0

See also

TuckerConv
CPConv

References

[2]Jean Kossaifi, Antoine Toisoul, Adrian Bulat, Yannis Panagakis, Timothy M. Hospedales, Maja Pantic; Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020, pp. 6060-6069
Attributes:
kernel_shapeint tuple

shape of the kernel weight parametrizing the full convolution

rankint

rank of the TT decomposition

Methods

full_weights() Returns the reconstructed full convolutional kernel
get_decomposition([return_bias]) Transpose back factors from a factorized version
init_from_decomposition(tt_tensor[, bias]) Transpose the factors from a full weight to the factorized version
init_from_random([decompose_full_weight]) Initialize the factorized convolution’s parameter randomly
init_from_tensor(kernel_tensor[, bias, …]) Initialize the factorized convolutional layer from a regular convolutional layer
transduct(kernel_size[, mode, padding, …]) Transduction of the factorized convolution to add a new dimension
init_from_tensor(kernel_tensor, bias=None, decomposition_kwargs={})[source]

Initialize the factorized convolutional layer from a regular convolutional layer

init_from_random(decompose_full_weight=True)[source]

Initialize the factorized convolution’s parameter randomly

Parameters:
decompose_full_weightbool

If True, a full weight is randomly created and decomposed to intialize the parameters (slower) Otherwise, the parameters are initialized directly (faster) so the reconstruction has a set variance.

init_from_decomposition(tt_tensor, bias=None)[source]

Transpose the factors from a full weight to the factorized version

Parameters:
factorstt_tensor
get_decomposition(return_bias=False)[source]

Transpose back factors from a factorized version

Parameters:
return_biasbool, default is False

if True also return the bias

Returns:
factors, bias if return_bias:
factors otherwise
full_weights()[source]

Returns the reconstructed full convolutional kernel

transduct(kernel_size, mode=0, padding=0, stride=1, dilation=1)[source]

Transduction of the factorized convolution to add a new dimension

Parameters:
kernel_sizeint

size of the additional dimension

modewhere to insert the new dimension, after the channels, default is 0

by default, insert the new dimensions before the existing ones (e.g. add time before height and width)

paddingint, default is 0
strideint: default is 1
Returns:
self