dsid271 commited on
Commit
3dd30e0
·
verified ·
1 Parent(s): 82f2feb

Delete tkat.py

Browse files
Files changed (1) hide show
  1. tkat.py +0 -16
tkat.py DELETED
@@ -1,16 +0,0 @@
1
- import tensorflow as tf
2
- from tensorflow.keras.layers import Layer, Dense
3
-
4
- class TKAT(Layer):
5
- def __init__(self, units):
6
- super(AttentionLayer, self).__init__()
7
- self.W1 = Dense(units)
8
- self.W2 = Dense(units)
9
- self.V = Dense(1)
10
-
11
- def call(self, query, values):
12
- score = self.V(tf.nn.tanh(self.W1(query) + self.W2(values)))
13
- attention_weights = tf.nn.softmax(score, axis=1)
14
- context_vector = attention_weights * values
15
- context_vector = tf.reduce_sum(context_vector, axis=1)
16
- return context_vector, attention_weights