17 lines
		
	
	
		
			511 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			17 lines
		
	
	
		
			511 B
		
	
	
	
		
			Python
		
	
	
	
	
	
|   | #!/usr/bin/env python3 | ||
|  | # -*- coding: utf-8 -*- | ||
|  | 
 | ||
|  | # Copyright 2020 Johns Hopkins University (Shinji Watanabe) | ||
|  | #                Northwestern Polytechnical University (Pengcheng Guo) | ||
|  | #  Apache 2.0  (http://www.apache.org/licenses/LICENSE-2.0) | ||
|  | """Swish() activation function for Conformer.""" | ||
|  | 
 | ||
|  | import torch | ||
|  | 
 | ||
|  | 
 | ||
|  | class Swish(torch.nn.Module): | ||
|  |     """Construct an Swish object.""" | ||
|  |     def forward(self, x: torch.Tensor) -> torch.Tensor: | ||
|  |         """Return Swish activation function.""" | ||
|  |         return x * torch.sigmoid(x) |