module emote.memory.table

Classes

class TableSerializationVersion(enum.Enum):

The version of the memory serialization format.

class MemoryTable(Protocol):

Fields

  • adaptors: List[Adaptor]

Methods

def sample(self, count, sequence_length) -> SampleResult

Sample COUNT traces from the memory, each consisting of SEQUENCE_LENGTH frames.

The data is transposed in a SoA fashion (since this is both easier to store and easier to consume).

Arguments:

  • count(int)
  • sequence_length(int)
def size(self) -> int

Query the number of elements currently in the memory.

def full(self) -> bool

Query whether the memory is filled.

def add_sequence(self, identity, sequence) -> None

Add a fully terminated sequence to the memory.

Arguments:

  • identity(int)
  • sequence
def store(self, path, version) -> bool

Persist the whole table and all metadata into the designated name.

Arguments:

  • path(str)
  • version(TableSerializationVersion)
def restore(self, path, override_version) -> bool

Restore the data table from the provided path. This also clears the data stores.

Arguments:

  • path(str)
  • override_version(TableSerializationVersion | None)

class ArrayMemoryTable:

Methods

def __init__(
    self
,
    *columns,
    maxlen,
    sampler,
    ejector,
    length_key,
    adaptors,
    device
) -> None

Create the table with the specified configuration.

Arguments:

  • columns(Sequence[Column])
  • maxlen(int)
  • sampler(SampleStrategy)
  • ejector(EjectionStrategy)
  • length_key
  • adaptors(Optional[Adaptor])
  • device(torch.device)
def resize(self, new_size) -> None
def clear(self) -> None

Clear and reset all data.

def sample(self, count, sequence_length) -> SampleResult

Sample COUNT traces from the memory, each consisting of SEQUENCE_LENGTH transitions.

The transitions are returned in a SoA fashion (since this is both easier to store and easier to consume)

Arguments:

  • count(int)
  • sequence_length(int)
def size(self) -> int

Query the number of elements currently in the memory.

def full(self) -> bool

Returns true if the memory has reached saturation, e.g., where new adds may cause ejection.

.. warning:: This does not necessarily mean that size() == maxlen, as we store and eject full sequences. The memory only guarantees we will have fewer samples than maxlen.

def add_sequence(self, identity, sequence) -> None
def store(self, path, version) -> bool

Persist the whole table and all metadata into the designated name.

Arguments:

  • path(str): The path to store the data to.
  • version(TableSerializationVersion): The serialization version to use.
def restore(self, path, override_version) -> bool