def __init__(self, config, weight=None): super(ElectraForSequenceClassification, self).__init__(config) self.num_labels = config.num_labels self.bert = ElectraModel(config) self.classifier = ElectraClassificationHead(config) self.init_weights()
def __init__(self, config, weight=None): super().__init__(config) self.num_labels = config.num_labels self.electra = ElectraModel(config) self.qa_outputs = nn.Linear(config.hidden_size, config.num_labels) self.init_weights()
def __init__(self, config): super().__init__() self._mask_prob = config.mask_prob self._mask_token_id = config.mask_token_id self._masking_strategy = config.masking_strategy self.backbone = ElectraModel(config) self.generator_head = GeneratorHead(config)
def __init__(self, config, weight=None): super().__init__(config) self.num_labels = config.num_labels self.electra = ElectraModel(config) self.pooler = ElectraPooler(config) self.dropout = nn.Dropout(config.hidden_dropout_prob) self.classifier = nn.Linear(config.hidden_size, self.config.num_labels) self.weight = weight
def __init__(self, config, pos_weight=None): super(ElectraForMultiLabelSequenceClassification, self).__init__(config) self.num_labels = config.num_labels self.pos_weight = pos_weight self.electra = ElectraModel(config) self.pooler = ElectraPooler(config) self.dropout = nn.Dropout(config.hidden_dropout_prob) self.classifier = nn.Linear(config.hidden_size, self.config.num_labels)
def __init__(self, config, pos_weight=None, regression=False, loss_fct=None): super(ElectraForMultiLabelSequenceClassification, self).__init__(config) self.num_labels = config.num_labels self.pos_weight = pos_weight self.electra = ElectraModel(config) self.pooler = ElectraPooler(config) self.dropout = nn.Dropout(config.hidden_dropout_prob) self.classifier = nn.Linear(config.hidden_size, self.config.num_labels) self.regression = regression if loss_fct is None: if self.regression: self.loss_fct = torch.nn.MSELoss() else: self.loss_fct = torch.nn.BCEWithLogitsLoss(pos_weight=self.pos_weight) elif loss_fct == "MAELoss": self.loss_fct = torch.nn.L1Loss() elif loss_fct == "MSELoss": self.loss_fct = torch.nn.MSELoss() self.init_weights()