9a76bb5272c3f8662b266410c0c5b0dbce3ec025,open_seq2seq/parts/rnns/attention_wrapper.py,LocationSensitiveAttention,__init__,#LocationSensitiveAttention#Any#Any#Any#Any#Any#Any#Any#Any#Any#,716

Before Change


    if probability_fn is None:
      probability_fn = nn_ops.softmax
    if dtype is None:
      dtype = dtypes.float32
    wrapped_probability_fn = lambda score, _: probability_fn(score)
    super(LocationSensitiveAttention, self).__init__(
        query_layer=layers_core.Dense(
            num_units, name="query_layer", use_bias=False, dtype=dtype
        ),
        memory_layer=layers_core.Dense(
            num_units, name="memory_layer", use_bias=False, dtype=dtype
        ),
        memory=memory,
        probability_fn=wrapped_probability_fn,
        memory_sequence_length=memory_sequence_length,
        score_mask_value=score_mask_value,
        name=name
    )
    self.location_layer = LocationLayer(32, 32, num_units)
    self._num_units = num_units
    self._name = name
    self.use_bias = use_bias
    self._use_state = use_state
    self.cumulative_location = self.initial_state(
        self._batch_size, dtype
    )

After Change


      `memory.shape[2:].is_fully_defined()`.
  
  memory = nest.map_structure(
      lambda m: ops.convert_to_tensor(m, name="memory"), memory
  )
  if memory_sequence_length is not None:
    memory_sequence_length = ops.convert_to_tensor(
        memory_sequence_length, name="memory_sequence_length"
    )
  if check_inner_dims_defined:

    def _check_dims(m):
      if not m.get_shape()[2:].is_fully_defined():
        raise ValueError(
            "Expected memory %s to have fully defined inner dims, "
            "but saw shape: %s" % (m.name, m.get_shape())
        )

    nest.map_structure(_check_dims, memory)
  if memory_sequence_length is None:
    seq_len_mask = None
  else:
    seq_len_mask = array_ops.sequence_mask(
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 13

Instances


Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 9a76bb5272c3f8662b266410c0c5b0dbce3ec025
Time: 2018-08-20
Author: jasoli@nvidia.com
File Name: open_seq2seq/parts/rnns/attention_wrapper.py
Class Name: LocationSensitiveAttention
Method Name: __init__


Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 9a76bb5272c3f8662b266410c0c5b0dbce3ec025
Time: 2018-08-20
Author: jasoli@nvidia.com
File Name: open_seq2seq/parts/rnns/attention_wrapper.py
Class Name: LocationSensitiveAttention
Method Name: __init__


Project Name: dmlc/gluon-nlp
Commit Name: 70a188776f7470c838dd22b1636462b75573a734
Time: 2020-07-16
Author: lausen@amazon.com
File Name: src/gluonnlp/sequence_sampler.py
Class Name: _MultinomialStepUpdate
Method Name: __init__


Project Name: shaypal5/pdpipe
Commit Name: 99095d5412483ec623278bdb1a0c9e24b18bfc85
Time: 2017-03-16
Author: shaypal5@gmail.com
File Name: pdpipe/basic_stages.py
Class Name: ValKeep
Method Name: __init__