r""" The approximate form of the Gaussian Error Linear Unit (GELU). For more details, see section 2 of this [paper](https://huggingface.co/papers/1606.08415). Parameters: dim_in (`int`): The number of channels in the input. dim_out (`int`): The number of channels in the
| 147 | |
| 148 | |
| 149 | class ApproximateGELU(nn.Module): |
| 150 | r""" |
| 151 | The approximate form of the Gaussian Error Linear Unit (GELU). For more details, see section 2 of this |
| 152 | [paper](https://huggingface.co/papers/1606.08415). |
| 153 | |
| 154 | Parameters: |
| 155 | dim_in (`int`): The number of channels in the input. |
| 156 | dim_out (`int`): The number of channels in the output. |
| 157 | bias (`bool`, defaults to True): Whether to use a bias in the linear layer. |
| 158 | """ |
| 159 | |
| 160 | def __init__(self, dim_in: int, dim_out: int, bias: bool = True): |
| 161 | super().__init__() |
| 162 | self.proj = nn.Linear(dim_in, dim_out, bias=bias) |
| 163 | |
| 164 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 165 | x = self.proj(x) |
| 166 | return x * torch.sigmoid(1.702 * x) |
| 167 | |
| 168 | |
| 169 | class LinearActivation(nn.Module): |
no outgoing calls
no test coverage detected
searching dependent graphs…