From 17a5607c392a8a1a71829ae1d48587c274eb9312 Mon Sep 17 00:00:00 2001 From: rolczynski Date: Mon, 17 Aug 2020 19:02:03 +0200 Subject: [PATCH] Note to remember that alignment after dot product --- aspect_based_sentiment_analysis/recognizers.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/aspect_based_sentiment_analysis/recognizers.py b/aspect_based_sentiment_analysis/recognizers.py index 337e9bc..5fbf99e 100644 --- a/aspect_based_sentiment_analysis/recognizers.py +++ b/aspect_based_sentiment_analysis/recognizers.py @@ -63,13 +63,24 @@ def __call__( # TODO: Re-implementation # cls_id, text_ids, aspect_id = self.get_indices(example) # + # attentions = alignment.merge_input_attentions( + # output_batch.attentions[i], + # alignment=example.alignment, + # reduce=True + # ) + # attention_grads = alignment.merge_input_attentions( + # attention_grads, + # alignment=example.alignment, + # reduce=True + # ) # threshold = 0.05 # round_decimals = 2 # # product = attentions * attention_grads # product = tf.abs(product) # product = tf.reduce_sum(product, axis=(0, 1)) - # # ... alignment + # attention_grads = alignment.merge_input( + # product, alignment=example.alignment) # product = product.numpy() # # w = product[cls_id, text_ids]