def __init__(self, num_classes=2): super().__init__() config = BertConfig(vocab_size_or_config_json_file=30522) config.output_hidden_states = True self.bert1 = modeling_bert.BertModel.from_pretrained('bert-base-cased') self.bert2 = modeling_bert.BertModel.from_pretrained('bert-base-cased') self.berts = [self.bert1, self.bert2] self.groups = 2 self.fc = nn.Linear(1536, num_classes)
def __init__(self, num_classes=2): super().__init__() config = BertConfig(vocab_size_or_config_json_file=30522) config.output_hidden_states = True #self.bert1 = torch.hub.load('huggingface/pytorch-pretrained-BERT', 'bertForQuestionAnswering', 'bert-base-cased', output_hidden_states=True) #self.bert2 = torch.hub.load('huggingface/pytorch-pretrained-BERT', 'bertForQuestionAnswering', 'bert-base-cased', output_hidden_states=True) self.bert1 = torch.hub.load('huggingface/pytorch-pretrained-BERT', 'bertModel', 'bert-base-cased') self.bert2 = torch.hub.load('huggingface/pytorch-pretrained-BERT', 'bertModel', 'bert-base-cased') #self.bert1 = BertForQuestionAnswering.from_pretrained(config=config) #self.bert2 = BertForQuestionAnswering.from_pretrained(config=config) #self.bert1 = BertModel.from_pretrained('bert-base-uncased') #self.bert2 = BertModel.from_pretrained('bert-base-uncased') self.fc = nn.Linear(1536, num_classes)