(curr_out, prev_mem, mem_len, reuse_len=None)
return tf.stop_gradient(new_mem)
cache hidden states into memory.
cache hidden states into memory.
cache hidden states into memory .
def _cache_mem(curr_out, prev_mem, mem_len, reuse_len=None):
  """cache hidden states into memory."""
  if mem_len is None or mem_len == 0:
    return None
  else:
    if reuse_len is not None and reuse_len > 0:
      curr_out = curr_out[:reuse_len]

    if prev_mem is None:
      new_mem = curr_out[-mem_len:]
    else:
      new_mem = tf.concat([prev_mem, curr_out], 0)[-mem_len:]

  return tf.stop_gradient(new_mem)
def _cache_mem ( curr_out , prev_mem , mem_len , reuse_len = None ) : if mem_len is None or mem_len == 0 : return None else : if reuse_len is not None and reuse_len > 0 : curr_out = curr_out [ : reuse_len ] if prev_mem is None : new_mem = curr_out [ - mem_len : ] else : new_mem = tf . concat ( [ prev_mem , curr_out ] , 0 ) [ - mem_len : ] return tf . stop_gradient ( new_mem )