threshold-demux8

1:8 demultiplexer. Routes data input to one of 8 outputs based on 3-bit select.

Function

DEMUX8(d, s2, s1, s0) -> [y0, y1, ..., y7]

yi = d AND (s == i), where s = 4s2 + 2s1 + s0

Architecture

Single layer with 8 neurons. Each output yi fires when d=1 AND select matches i.

Output Weights [d, s2, s1, s0] Bias
y0 [1, -1, -1, -1] -1
y1 [1, -1, -1, +1] -2
y2 [1, -1, +1, -1] -2
y3 [1, -1, +1, +1] -3
y4 [1, +1, -1, -1] -2
y5 [1, +1, -1, +1] -3
y6 [1, +1, +1, -1] -3
y7 [1, +1, +1, +1] -4

Parameters

Inputs 4 (1 data + 3 select)
Outputs 8
Neurons 8
Layers 1
Parameters 40
Magnitude 52

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def demux8(d, s2, s1, s0):
    inp = torch.tensor([float(d), float(s2), float(s1), float(s0)])
    return [int((inp * w[f'y{i}.weight']).sum() + w[f'y{i}.bias'] >= 0)
            for i in range(8)]

# Route d=1 to output 5 (s=101)
print(demux8(1, 1, 0, 1))  # [0, 0, 0, 0, 0, 1, 0, 0]

License

MIT

Downloads last month
10
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/threshold-demux8