Views
No views yet
| a | b | c | d | sum | out |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 1 | 2 | 0 |
| ... | |||||
| 1 | 1 | 1 | 1 | 4 | 0 |
Layer 1:
N1: [1,1,1,1] b=-1 (fires when sum >= 1)
N2: [-1,-1,-1,-1] b=1 (fires when sum <= 1)
Layer 2:
AND: [1,1] b=-2 (fires when both N1 and N2 fire)| Inputs | 4 |
| Outputs | 1 |
| Neurons | 3 |
| Layers | 2 |
| Parameters | 13 |
| Magnitude | 14 |
1from safetensors.torch import load_file
2import torch
3
4w = load_file('model.safetensors')
5
6def exactly1of4(a, b, c, d):
7 inp = torch.tensor([float(a), float(b), float(c), float(d)])
8 l1 = (inp @ w['layer1.weight'].T + w['layer1.bias'] >= 0).float()
9 out = (l1 @ w['layer2.weight'].T + w['layer2.bias'] >= 0).float()
10 return int(out.item())
11
12print(exactly1of4(0, 0, 0, 1)) # 1
13print(exactly1of4(0, 0, 1, 1)) # 0