espnet2.layers.sinc_conv.LogCompression
Less than 1 minute
espnet2.layers.sinc_conv.LogCompression
class espnet2.layers.sinc_conv.LogCompression
Bases: Module
Log Compression Activation.
This class implements the Log Compression activation function, defined as log(abs(x) + 1), which is applied elementwise to the input tensor. This activation function is particularly useful in neural networks for compressing the range of input values.
None
- Parameters:None
- Returns: The output tensor after applying the Log Compression function.
- Return type: torch.Tensor
####### Examples
>>> log_compression = LogCompression()
>>> input_tensor = torch.tensor([-1.0, 0.0, 1.0])
>>> output_tensor = log_compression(input_tensor)
>>> print(output_tensor)
tensor([0.3133, 0.0000, 0.3133])
Initialize.
forward(x: Tensor) → Tensor
Forward pass of the Log Compression Activation.
Applies the Log Compression function elementwise on the input tensor x, which is defined as log(abs(x) + 1). This activation function is useful for compressing the range of input values, particularly in deep learning models.
- Parameters:x (torch.Tensor) – The input tensor for which the Log Compression function is to be applied. The tensor can be of any shape.
- Returns: A tensor of the same shape as input x, containing the elementwise results of the Log Compression function.
- Return type: torch.Tensor
####### Examples
>>> import torch
>>> log_compression = LogCompression()
>>> input_tensor = torch.tensor([-1.0, 0.0, 1.0])
>>> output_tensor = log_compression(input_tensor)
>>> print(output_tensor)
tensor([0.6931, 0.0000, 0.6931])