Skip to content

Logic Function Datasets

Defined in: griffith_logic.datasets.logic.truth_table_dataset (function)

def truth_table_dataset(
table: TruthTable,
n_inputs: int,
n_outputs: int,
repeat: int = 1,
) -> TensorDataset

Builds a TensorDataset enumerating all 2^n_inputs rows of a truth table.

Arguments

  • table — the truth table. Either a function fn(tuple of input bits) -> output bits, a list of output bit strings (in butterfly pattern order: bit j of pattern k = (k>>j)&1), or a mapping {tuple of input bits | pattern number k: output bits}
  • n_inputs — number of input bits
  • n_outputs — number of output bits
  • repeat — how many times to replicate the full pattern set (to tune epochs in batch training)

Returns

TensorDataset(X, Y). X: (2^n_inputs·repeat, n_inputs) float32 {0,1}, Y: (2^n_inputs·repeat, n_outputs) float32 {0,1}

Defined in: griffith_logic.datasets.logic.LogicDatasetSpec (class)

class LogicDatasetSpec(name: str, n_inputs: int, n_outputs: int, dataset: TensorDataset)

Specification of a logic function dataset (the unit looked up from the registry by, for example, the editor backend)

Defined in: griffith_logic.datasets.logic.LOGIC_DATASETS (constant)

LOGIC_DATASETS: dict[str, Callable[..., LogicDatasetSpec]]

(no docstring yet)