FiniteStateAutomata
- class torchhd.structures.FiniteStateAutomata(dimensions, vsa: Literal['BSC', 'MAP', 'HRR', 'FHRR', 'BSBC', 'VTB', 'MCR', 'CGR'] = 'MAP', device=None, dtype=None)[source]
Hypervector-based finite state automata data structure.
Creates an empty finite state automata.
- Parameters:
dimensions (int) – dimensions of the automata.
vsa – (
VSAOptions, optional): specifies the hypervector type and operations used (Default:"MAP").dtype (
torch.dtype, optional) – the desired data type of returned tensor. Default: ifNone, uses a global default (seetorch.set_default_tensor_type()).device (
torch.device, optional) – the desired device of returned tensor. Default: ifNone, uses the current device for the default tensor type (see torch.set_default_tensor_type()).devicewill be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.
Examples:
>>> FSA = structures.FiniteStateAutomata(10000)
- add_transition(token: VSATensor, initial_state: VSATensor, final_state: VSATensor) None[source]
Adds a transition to the automata.
- Parameters:
Examples:
>>> letters = list(string.ascii_lowercase) >>> letters_hv = torchhd.random(len(letters), 10000) >>> T.add_transition(letters_hv[0], letters_hv[1], letters_hv[2])