threshold-nor4 / README.md
phanerozoic's picture
Upload folder using huggingface_hub
e9afe3b verified
---
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
---
# threshold-nor4
4-input NOR gate. Outputs 1 only when all inputs are 0.
## Circuit
```
x1 x2 x3 x4
β”‚ β”‚ β”‚ β”‚
β””β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚w:-1,-1,-1,-1β”‚
β”‚ b: 0 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
NOR4(x1,x2,x3,x4)
```
## Parameters
| | |
|---|---|
| Weights | [-1, -1, -1, -1] |
| Bias | 0 |
| Magnitude | 4 |
## Optimality
Exhaustive enumeration of 681 configurations confirms magnitude 4 is optimal. 1 valid configuration exists.
| Magnitude | Valid Configs |
|-----------|---------------|
| 0-3 | 0 |
| 4 | 1 |
## Usage
```python
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def nor4(x1, x2, x3, x4):
inputs = torch.tensor([float(x1), float(x2), float(x3), float(x4)])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
```
## License
MIT