| 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 | |