vertical_compression
#
- hypercoil.functional.sylo.vertical_compression(input: Tensor, row_compressor: Tensor, col_compressor: Tensor | None = None, renormalise: bool = True, remove_diagonal: bool = False, fold_channels: bool = False, sign: int | None = None) Tensor [source]#
Vertically compress a matrix or matrix stack of dimensions \(H_{in} \times W_{in} \rightarrow H_{out} \times W_{out}\).
- Parameters:
- input: Tensor
Tensor to be compressed. This can be either a matrix of dimension \(H_{in} \times W_{in}\) or a stack of such matrices, for instance of dimension \(N \times C \times H_{in} \times W_{in}\).
- row_compressor: Tensor
Compressor for the rows of the input tensor. This should be a matrix of dimension \(H_{out} \times H_{in}\).
- col_compressor: Tensor or None
Compressor for the columns of the input tensor. This should be a matrix of dimension \(W_{out} \times W_{in}\). If this is None, then symmetry is assumed: the column compressor and row compressor are the same.
- renormalise: bool
If True, the output is renormalised to have standard deviation equal to that of the input. When
remove_diagonal=True
, the standard deviation also ignores the diagonal elements.- remove_diagonal: bool
If True, the diagonal elements of the input are removed before and after compression.
- sign: int or None
If not None, this should be either 1 or -1. If -1, the output is multiplied by -1.
- Returns:
- output: Tensor
Compressed tensor.