threshold-not / README.md
CharlesCNorton
Add optimality note: exhaustive enumeration confirms magnitude 1 is minimum
51c400d
---
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
---
# threshold-not
The minimal threshold circuit. One neuron, one weight, one bias.
## Circuit
```
x
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚ w: -1 β”‚
β”‚ b: 0 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
NOT(x)
```
## Mechanism
A threshold neuron fires when its weighted input plus bias reaches zero. NOT uses weight -1 and bias 0:
- Input 0: sum = 0, fires (output 1)
- Input 1: sum = -1, silent (output 0)
The negative weight flips the relationship between input magnitude and firing.
## Parameters
| | |
|---|---|
| Weight | -1 |
| Bias | 0 |
| Total | 2 parameters |
## Optimality
Exhaustive enumeration of all 5 weight configurations at magnitudes 0-1 confirms this circuit is **already at minimum magnitude (1)**. There is exactly one valid configuration at magnitude 1, and no valid configurations exist below it.
## Properties
- Involutive: NOT(NOT(x)) = x
- Foundation for NAND, NOR
## Usage
```python
from safetensors.torch import load_file
w = load_file('model.safetensors')
def not_gate(x):
return int(x * w['weight'].item() + w['bias'].item() >= 0)
```
## Files
```
threshold-not/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ config.json
└── README.md
```
## License
MIT