deepy/layers/attention.py
def compute_context_vector(self, prev_state, inputs, precomputed_values=None, mask=None):
        """
        Compute the context vector with soft attention.
        """
        precomputed_values = precomputed_values if precomputed_values else self.precompute(inputs)
        align_weights = self.compute_alignments(prev_state, precomputed_values, mask)
        context_vector = T.sum(align_weights[:, :, None] * inputs, axis=1)
        return context_vector
def compute_context_vector(self, prev_state, inputs, precomputed_values=None, mask=None):
        precomputed_values = precomputed_values if precomputed_values else self.precompute(inputs)
        align_weights = self.compute_alignments(prev_state, precomputed_values, mask)
        context_vector = T.sum(align_weights[:, :, None] * inputs, axis=1)
        return context_vector
def compute_context_vector ( self , prev_state , inputs , precomputed_values = None , mask = None ) : precomputed_values = precomputed_values if precomputed_values else self . precompute ( inputs ) align_weights = self . compute_alignments ( prev_state , precomputed_values , mask ) context_vector = T . sum ( align_weights [ : , : , None ] * inputs , axis = 1 ) return context_vector
Compute the context vector with soft attention.
Compute the context vector with soft attention .