Views
No views yet
| a | b | c | sum | out |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 2 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 2 | 1 |
| 1 | 1 | 0 | 2 | 1 |
| 1 | 1 | 1 | 3 | 0 |
| Inputs | 3 |
| Outputs | 1 |
| Neurons | 3 |
| Layers | 2 |
| Parameters | 11 |
| Magnitude | 14 |
1from safetensors.torch import load_file
2import torch
3
4w = load_file('model.safetensors')
5
6def exactly2of3(a, b, c):
7 inp = torch.tensor([float(a), float(b), float(c)])
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(exactly2of3(0, 1, 1)) # 1 (sum=2)
13print(exactly2of3(1, 1, 1)) # 0 (sum=3)