Miscellaneous
einconv.index_pattern
index_pattern(input_size: int, kernel_size: int, stride: int = 1, padding: Union[int, str] = 0, dilation: int = 1, device: torch.device = cpu, dtype: torch.dtype = torch.bool) -> Tensor
Compute the connectivity pattern tensor of a convolution along one dimension.
Uses one-dimensional convolution under the hood.
Parameters:
-
input_size
(int
) –Spatial input dimension of the convolution.
-
kernel_size
(int
) –Kernel size along dimension.
-
stride
(int
, default:1
) –Stride along dimension. Default:
1
. -
padding
(Union[int, str]
, default:0
) –Padding along dimension. Can be an integer or a string. Allowed strings are
'same'
and'valid'
. Default:0
. -
dilation
(int
, default:1
) –Dilation along dimension. Default:
1
. -
device
(device
, default:cpu
) –Execution device. Default:
'cpu'
. -
dtype
(dtype
, default:bool
) –Data type of the pattern tensor. Default:
torch.bool
.
Returns:
-
Tensor
–Index pattern tensor. Has shape
[kernel_size, output_size, input_size]
and the specified data type. Its element[k, o, i]
isTrue
(or equivalent cast) if elementi
of the input contributes to output elemento
via thek
th kernel entry (False
otherwise). The hyper-parameters are stored under the tensor's._pattern_hyperparams
attribute.