Beispiel #1
0
    def build_read_mask(self):
        """Creates a mask which allows us to attenuate subsequent read strengths.

    This is exposed as it's own function so that it can be overridden to provide
    alternate read adressing schemes.

    Returns:
      A tf.float32 tensor of shape [1, memory_size, memory_size]
    """
        return common_layers.mask_pos_gt(self._memory_size, self._memory_size)
Beispiel #2
0
    def get_read_mask(self, read_head_index):
        """Uses mask_pos_lt() instead of mask_pos_gt() to reverse read values.

    Args:
      read_head_index: Identifies which read head we're getting the mask for.

    Returns:
      A tf.float32 tensor of shape [1, 1, memory_size, memory_size].
    """
        return tf.expand_dims(common_layers.mask_pos_gt(
            self._memory_size, self._memory_size),
                              axis=0)
Beispiel #3
0
 def get_read_mask(self, read_head_index):
   if read_head_index == 0:
     # Use the same read mask as the queue for the bottom of the deque.
     return tf.expand_dims(
         common_layers.mask_pos_gt(self._memory_size, self._memory_size),
         axis=0)
   elif read_head_index == 1:
     # Use the same read mask as the stack for the top of the deque.
     return tf.expand_dims(
         common_layers.mask_pos_lt(self._memory_size, self._memory_size),
         axis=0)
   else:
     raise ValueError("Read head index must be either 0 or 1 for deque.")