| 197 | class PoolerClassify(PoolerActivation): |
| 198 | |
| 199 | def __init__(self, *, static_num_labels: bool = True) -> None: |
| 200 | super().__init__() |
| 201 | |
| 202 | if static_num_labels: |
| 203 | fd_config = FDConfig() |
| 204 | self.num_labels = getattr(fd_config.model_config, "num_labels", 0) |
| 205 | if self.num_labels == 0: |
| 206 | logger.warning( |
| 207 | "num_labels should be > 0 for classification" |
| 208 | "models, falling back to softmax. " |
| 209 | "Please check if the configuration is correct." |
| 210 | ) |
| 211 | else: |
| 212 | self.num_labels = None |
| 213 | |
| 214 | def forward_chunk(self, pooled_data: paddle.Tensor) -> paddle.Tensor: |
| 215 | num_labels = self.num_labels if self.num_labels is not None else pooled_data.shape[-1] |