tltorch.factorized_conv.TuckerConv

class tltorch.factorized_conv.TuckerConv(*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 Tucker conv is expressed as a series of smaller 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
modes_fixed_rankNone, ‘spatial’ or int list, default is None

if ‘spatial’, the rank along the spatial dimensions is kept the same as the original dimension if int list, the rank is kept fixed (same as input) along the specified modes otherwise (if None), all the ranks are determing

used only if rank is ‘same’ or a float.

See also

CPConv
TTConvs

References

[1]Yong-Deok Kim, Eunhyeok Park, Sungjoo Yoo, TaelimChoi, Lu Yang, and Dongjun Shin. Compression of deep convolutional neural networks for fast and low power mobile applications. In ICLR, 2016.
[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 Tucker decomposition

Methods

get_decomposition([return_bias]) Returns the Tucker Tensor parametrizing the convolution
init_from_decomposition(tucker_tensor[, bias]) Initialize the factorized convolution with a decomposed tensor
init_from_random([decompose_full_weight]) Initialize the factorized convolution’s parameter randomly
init_from_tensor(kernel_tensor[, bias, …]) Initializes the factorized convolution by decomposing a full tensor.
init_from_tensor(kernel_tensor, bias=None, decomposition_kwargs={})[source]

Initializes the factorized convolution by decomposing a full tensor.

Parameters:
kernel_tensorfull convolutional kernel to decompose
biasoptional, default is None
decomposition_kwargsdict

dictionary of parameters passed on to the decomposition

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(tucker_tensor, bias=None)[source]

Initialize the factorized convolution with a decomposed tensor

Parameters:
factorsTucker tensor

(core, factors) of the Tucker tensor

get_decomposition(return_bias=False)[source]

Returns the Tucker Tensor parametrizing the convolution

Parameters:
return_biasbool, default is False

if True also return the bias

Returns:
(core, factors), bias if return_bias:
(core, factors) otherwise