コード例 #1
0
 def create_and_check_flaubert_model(
     self,
     config,
     input_ids,
     token_type_ids,
     input_lengths,
     sequence_labels,
     token_labels,
     is_impossible_labels,
     choice_labels,
     input_mask,
 ):
     model = FlaubertModel(config=config)
     model.to(torch_device)
     model.eval()
     outputs = model(input_ids, lengths=input_lengths, langs=token_type_ids)
     outputs = model(input_ids, langs=token_type_ids)
     outputs = model(input_ids)
     sequence_output = outputs[0]
     result = {
         "sequence_output": sequence_output,
     }
     self.parent.assertListEqual(
         list(result["sequence_output"].size()),
         [self.batch_size, self.seq_length, self.hidden_size])
コード例 #2
0
    def __init__(self, config, pos_weight=None):
        super(FlaubertForMultiLabelSequenceClassification, self).__init__(config)
        self.num_labels = config.num_labels
        self.pos_weight = pos_weight

        self.transformer = FlaubertModel(config)
        self.sequence_summary = SequenceSummary(config)

        self.init_weights()
コード例 #3
0
 def create_and_check_flaubert_model(
     self,
     config,
     input_ids,
     token_type_ids,
     input_lengths,
     sequence_labels,
     token_labels,
     is_impossible_labels,
     choice_labels,
     input_mask,
 ):
     model = FlaubertModel(config=config)
     model.to(torch_device)
     model.eval()
     result = model(input_ids, lengths=input_lengths, langs=token_type_ids)
     result = model(input_ids, langs=token_type_ids)
     result = model(input_ids)
     self.parent.assertEqual(result.last_hidden_state.shape, (self.batch_size, self.seq_length, self.hidden_size))