metadata
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
threshold-demux16
1:16 demultiplexer. Routes data input to one of 16 outputs based on 4-bit select.
Function
DEMUX16(d, s3, s2, s1, s0) -> [y0..y15]
yi = d AND (s == i), where s = 8s3 + 4s2 + 2*s1 + s0
Architecture
Single layer with 16 neurons. Each output yi fires when d=1 AND select matches i.
Each neuron has:
- Weight on d: +1
- Weights on select bits: +1 if that bit is 1 in i, else -1
- Bias: -(1 + popcount(i))
Parameters
| Inputs | 5 (1 data + 4 select) |
| Outputs | 16 |
| Neurons | 16 |
| Layers | 1 |
| Parameters | 96 |
| Magnitude | 128 |
Usage
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def demux16(d, s3, s2, s1, s0):
inp = torch.tensor([float(d), float(s3), 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(16)]
# Route d=1 to output 10 (s=1010)
print(demux16(1, 1, 0, 1, 0)) # [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]
License
MIT