Beispiel #1
0
    def __init__(self, config):
        super(SpanAttention, self).__init__()
        # create modules
        self.attention = SpanWordAttention(config)
        self.output = BertSelfOutput(config)

        # initialize weights
        self.init_weights()
Beispiel #2
0
 def __init__(self, config, add_conditional_layernorm=True):
     super().__init__(config)
     self.self = MyBertSelfAttention10(config)
     self.add_conditional_layernorm = add_conditional_layernorm
     if add_conditional_layernorm:
         self.output = MyBertSelfOutput10(config)
     else:
         self.output = BertSelfOutput(config)
     self.pruned_heads = set()
Beispiel #3
0
    def __init__(self, config: BertConfig, bias=False):
        super().__init__()

        self.config = config

        self.head_num = config.num_attention_heads
        self.head_dim = config.hidden_size // self.head_num
        self.all_dim = self.head_num * self.head_dim

        self.query = nn.Linear(config.hidden_size, self.all_dim, bias=bias)
        self.kv = nn.Linear(config.hidden_size, self.all_dim, bias=bias)

        self.output = BertSelfOutput(config)

        self.dropout = nn.Dropout(config.attention_probs_dropout_prob)

        self.scale = 1 / (self.head_dim**0.5)
Beispiel #4
0
 def __init__(self, config):
     super(EntityAwareAttention, self).__init__()
     self.self = EntityAwareSelfAttention(config)
     self.output = BertSelfOutput(config)
Beispiel #5
0
 def __init__(self, config):
     super(BertAttention, self).__init__()
     self.self = BertSelfAttention(config)
     self.output = BertSelfOutput(config)
     self.pruned_heads = set()
Beispiel #6
0
 def __init__(self, config):
     super().__init__()
     self.att = BertSelfAttention(config)
     self.output = BertSelfOutput(config)
 def __init__(self, config):
     super().__init__()
     self.self = BertScanAttentionHeads(config)
     self.output = BertSelfOutput(config)
Beispiel #8
0
 def __init__(self, config):
     super(CaptionBertAttention, self).__init__(config)
     self.self = CaptionBertSelfAttention(config)
     self.output = BertSelfOutput(config)
Beispiel #9
0
 def __init__(self, config):
     super(BertAttention_attention, self).__init__()
     self.self = BertSelfAttention_attention(config)
     self.output = BertSelfOutput(config)