Package: torchConvNd
A library to compute N-D convolutions, transposed convolutions and recursive convolution in pytorch, usingLinearfilter or arbitrary functions as filter. It also gives the option of automaticly finding convolution parameters to match a desired output shape.InstalationUsepip3 install torchConvNdDocumentationconvNdconvNd(x,weight,kernel,stride=1,dilation=1,padding=0,bias=None,padding_mode='constant',padding_value=0)N-Dimensional convolution.Inputs:x:torch.tensorof shape(batch_size, C_in, *shape).Weight:torch.tensorof size(C_in * kernel[0] * kernel[1] * ...kernel[n_dims], C_out).kernel: array-like or int, kernel size of the convolution.stride: array-like or int, stride length of the convolution.dilation: array-like or int, dilation of the convolution.padding:None, array-like or int, padding size.bias:Noneortorch.tensorof size(C_out, ).padding_mode,padding_value: seepad.Outputs:out:torch.tensorof shape(batch_size, C_out, *shape_out).ConvNdConvNd(in_channels,out_channels,kernel,stride=1,dilation=1,padding=0,bias=False,padding_mode='constant',padding_value=0)Equivalent ofconvNdas atorch.nn.Moduleclass.Inputs:in_channels: int, number of in channels.out_channels: int, number of out channels.bias: boolean, controls the usage or not of biases.kernel,stride,dilation,padding,padding_mode,padding_value: Same as inconvNd.convTransposeNdconvTransposeNd(x,weight,kernel,stride=1,dilation=1,padding=0,bias=None,padding_mode='constant',padding_value=0)Transposed convolution (usingrepeat_intereleave).Inputs:x:torch.tensorof shape(batch_size, C_in, *shape).Weight:torch.tensorof size(C_in * kernel[0] * kernel[1] * ...kernel[n_dims], C_out).kernel: array-like or int, kernel size of the transposed convolution.stride: array-like or int, stride length of the transposed convolution.dilation: array-like or int, dilation of the convolution.padding:None, array-like or int, padding size.bias:Noneortorch.tensorof size(C_out, ).padding_mode,padding_value: seepad.Outputs:out:torch.tensorof shape(batch_size, *shape_out).ConvTransposeNdConvTransposeNd(in_channels,out_channels,kernel,stride=1,dilation=1,padding=0,bias=None,padding_mode='constant',padding_value=0)Equivalent ofconvTransposeNdas atorch.nn.Moduleclass.Inputs:in_channels: int, number of in channels.out_channels: int, number of out channels.bias: boolean, controls the usage or not of biases.kernel,stride,dilation,padding,padding_mode,padding_value: Same as inconvTransposeNd.convNdFuncconvNdFunc(x,func,kernel,stride=1,padding=0,stride_transpose=1,padding_mode='constant',padding_value=0,*args)Equivalent ofconvNdusing an arbitrary filterfunc.Inputs:x:torch.tensorof shape(batch_size, C_in, *shape).func: function, taking atorch.tensorof shape(batch_size, C_in, *kernel)and outputs atorch.tensorof shape(batch_size, C_out).kernel: array-like or int, kernel size of the  convolution.stride: array-like or int, stride length of the convolution.dilation: array-like or int, dilation of the convolution.padding:None, array-like or int, padding size.stride_transpose: array-like or int, equivalent tostrideinconvTransposeNd.padding_mode,padding_value: seepad.*args: additional arguments to pass tofunc.Outputs:out:torch.tensorof shape(batch_size, *shape_out).*(additional returns): any additional returns offunc.ConvNdFuncConvNdFunc(func,kernel,stride=1,padding=0,padding_mode='constant',padding_value=0)Equivalent ofconvNdFuncas atorch.nn.Moduleclass.Inputs:func,kernel,stride,dilation,padding,stride_transpose,padding_mode,padding_value: Same as inconvNdFunc.torchConvNd.Utilslistifylistify(x,dims=1)Transformxto an iterable if it is not.Inputs:x: array like or non iterable object (or string), object to listify.dims: int, array size to obtain.Outputs:out:  array like, listified version of x.convShapeconvShape(input_shape,kernel,stride=1,dilation=1,padding=0,stride_transpose=1)Compute the ouput shape of a convolution.Inputs:input_shape: array-like or int, shape of the input tensor.kernel: array-like or int, kernel size of the convolution.stride: array-like or int, stride length of the convolution.dilation: array-like or int, dilation of the convolution.padding:None, array-like or int, padding size.stride_transpose: array-like or int, equivalent tostrideinconvTransposeNd.Outputs:shape: array-like or int, predicted output shape of the convolution.autoShapeautoShape(input_shape,kernel,output_shape,max_dilation=3)Compute the optimal parametersstride,dilation,paddingandstride_transposeto matchoutput_shape.Inputs:input_shape: array-like or int, shape of the input tensor.kernel: array-like or int, kernel size of the  convolution.output_shape: array-like or int, target shape of the convolution.max_dilation: array-like or int, maximum value of dialtion.Outputs:kernel: array-like or int,listified(kernel, len(input_shape))ifinput_shapeis a list, elsekernel.stride: array-like or int, stride length of the convolution.dilation: array-like or int, dilation of the convolution.padding: array-like or int, padding size.stride_transpose: array-like or int, equivalent tostrideinconvTransposeNd.padpad(x,padding,padding_mode='constant',padding_value=0)Based ontorch.nn.functional.pad.Inputs:x:torch.tensor, input tensor.padding: array-like or int, size of the padding (identical on each size).padding_mode: 'constant', 'reflect', 'replicate' or 'circular', seetorch.nn.functional.pad.padding_value: float, value to pad with ifpadding_modeid 'constant'.Outputs:out:torch.tensor, paded tensor.PadPad(padding,padding_mode='constant',padding_value=0)Equivalent ofpadwhich returns a function.Inputs:padding,padding_mode,padding_value: same as withpadviewview(x,kernel,stride=1)Generate a view (for a convolution) with parameterskernelandstride.Inputs:x:torch.tensor, input tensor.kernel: array-like or int, kernel size of the convolution.stride: array-like or int, stride length of the convolution.Outputs:out:torch.tensor, strided tensor.ViewView(kernel,stride=1)Equivalent ofviewwhich returns a function.Inputs:kernel,stride: same as inview.FlattenFlatten()Atorch.nn.Moduleclass that takes a tensor of shape(N, i, j, k...)and reshape it to(N, i*j*k*...).ReshapeReshape(shape)Atorch.nn.Moduleclass that takes a tensor of shape(N, i)and reshape it to(N, *shape).Inputs:shape: array-like or int, shape to obtain.ClipClip(shape)Atorch.nn.Modulethat takes a slice of a tensor of sizeshape(in the center).Inputs:shape: array-like or int, shape to obtain (doesn't affect an axis whereshape=-1).