Views
No views yet
x y
│ │
├───┬───┤
│ │ │
▼ │ ▼
┌──────┐│┌──────┐
│ NOR │││ AND │ Layer 1
│w:-1,-1││w:1,1 │
│b: 0 │││b: -2 │
└──────┘│└──────┘
│ │ │
└───┼───┘
▼
┌──────┐
│ OR │ Layer 2
│w: 1,1│
│b: -1 │
└──────┘
│
▼
x ↔ y| x | y | NOR | AND | x ↔ y |
|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 |
| Layer | Weights | Bias |
|---|---|---|
| NOR | [-1, -1] | 0 |
| AND | [1, 1] | -2 |
| OR | [1, 1] | -1 |
| Total | 9 |
1from safetensors.torch import load_file
2import torch
3
4w = load_file('model.safetensors')
5
6def biimplies_gate(x, y):
7 inp = torch.tensor([float(x), float(y)])
8
9 nor_out = int((inp * w['layer1.neuron1.weight']).sum() + w['layer1.neuron1.bias'] >= 0)
10 and_out = int((inp * w['layer1.neuron2.weight']).sum() + w['layer1.neuron2.bias'] >= 0)
11
12 l1 = torch.tensor([float(nor_out), float(and_out)])
13 return int((l1 * w['layer2.weight']).sum() + w['layer2.bias'] >= 0)threshold-biimplies/
├── model.safetensors
├── model.py
├── config.json
└── README.md