Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
•
248 items
•
Updated
•
1
4-bit buffer (identity function). Passes input through unchanged.
buffer4(x3, x2, x1, x0) -> (y3, y2, y1, y0)
Output equals input: y_i = x_i for all i.
| Input | Output |
|---|---|
| 0000 | 0000 |
| 0001 | 0001 |
| ... | ... |
| 1111 | 1111 |
Single-layer, each output independently buffers one input:
x3 x2 x1 x0
│ │ │ │
â–¼ â–¼ â–¼ â–¼
â—‹ â—‹ â—‹ â—‹ Layer 1
│ │ │ │
â–¼ â–¼ â–¼ â–¼
y3 y2 y1 y0
Each neuron: w=[...,1,...], b=-1 (single input with weight 1).
| Inputs | 4 |
| Outputs | 4 |
| Neurons | 4 |
| Layers | 1 |
| Parameters | 20 |
| Magnitude | 8 |
While trivial, buffers serve several purposes:
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def buffer(x3, x2, x1, x0):
inp = torch.tensor([float(x3), float(x2), float(x1), float(x0)])
y0 = int((inp @ w['y0.weight'].T + w['y0.bias'] >= 0).item())
y1 = int((inp @ w['y1.weight'].T + w['y1.bias'] >= 0).item())
y2 = int((inp @ w['y2.weight'].T + w['y2.bias'] >= 0).item())
y3 = int((inp @ w['y3.weight'].T + w['y3.bias'] >= 0).item())
return y3, y2, y1, y0
MIT