Views
No views yet
| Inputs | 5 |
| Outputs | 1 |
| Neurons | 12 |
| Layers | 6 |
| Parameters | 36 |
| Magnitude | 40 |
1from safetensors.torch import load_file
2
3w = load_file('model.safetensors')
4
5def xor2(a, b, prefix):
6 or_out = int(a * w[f'{prefix}.or.weight'][0] + b * w[f'{prefix}.or.weight'][1] + w[f'{prefix}.or.bias'] >= 0)
7 nand_out = int(a * w[f'{prefix}.nand.weight'][0] + b * w[f'{prefix}.nand.weight'][1] + w[f'{prefix}.nand.bias'] >= 0)
8 return int(or_out * w[f'{prefix}.and.weight'][0] + nand_out * w[f'{prefix}.and.weight'][1] + w[f'{prefix}.and.bias'] >= 0)
9
10def parity5(a, b, c, d, e):
11 xor_ab = xor2(a, b, 'xor_ab')
12 xor_cd = xor2(c, d, 'xor_cd')
13 xor_abcd = xor2(xor_ab, xor_cd, 'xor_abcd')
14 return xor2(xor_abcd, e, 'xor_final')
15
16print(parity5(1, 0, 1, 0, 1)) # 1 (odd)
17print(parity5(1, 1, 1, 1, 0)) # 0 (even)