Views
No views yet
| x3 | x2 | x1 | x0 | w_sum | y |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 6 | 1 |
| 1 | 0 | 0 | 0 | 4 | 0 |
| 1 | 0 | 1 | 0 | 6 | 1 |
| 1 | 1 | 0 | 0 | 7 | 1 |
| 1 | 1 | 1 | 1 | 10 | 1 |
x3 ──(×4)──┐
x2 ──(×3)──┼──► Σ ──► (≥6?) ──► y
x1 ──(×2)──┤
x0 ──(×1)──┘| Inputs | 4 |
| Outputs | 1 |
| Neurons | 1 |
| Layers | 1 |
| Parameters | 5 |
| Magnitude | 16 |
1from safetensors.torch import load_file
2import torch
3
4w = load_file('model.safetensors')
5
6def weighted(x3, x2, x1, x0):
7 inp = torch.tensor([float(x3), float(x2), float(x1), float(x0)])
8 return int((inp @ w['y.weight'].T + w['y.bias'] >= 0).item())
9
10# weighted(1, 0, 1, 0) = 1 # 4+2=6 >= 6
11# weighted(1, 0, 0, 1) = 0 # 4+1=5 < 6