Views
No views yet
x₀ x₁ x₂ x₃
│ │ │ │
├───────┼───────┼───────┤
│ │ │ │
▼ ▼ ▼ ▼
┌──────┐┌──────┐┌──────┐┌──────┐
│ y₀ ││ y₁ ││ y₂ ││ y₃ │
│+1 -1 ││-1 +1 ││-1 -1 ││-1 -1 │
│-1 -1 ││-1 -1 ││+1 -1 ││-1 +1 │
│b: -1 ││b: -1 ││b: -1 ││b: -1 │
└──────┘└──────┘└──────┘└──────┘
│ │ │ │
▼ ▼ ▼ ▼
y₀ y₁ y₂ y₃| Inputs | Outputs | Interpretation |
|---|---|---|
| 0000 | 0000 | No input, no winner |
| 1000 | 1000 | x₀ wins |
| 0100 | 0100 | x₁ wins |
| 0010 | 0010 | x₂ wins |
| 0001 | 0001 | x₃ wins |
| 1100 | 0000 | Tie - no winner |
| 1010 | 0000 | Tie - no winner |
| 1111 | 0000 | All active - no winner |
sum = (+1)·x₀ + (-1)·x₁ + (-1)·x₂ + (-1)·x₃ - 1
= x₀ - x₁ - x₂ - x₃ - 1| HW | WTA Output |
|---|---|
| 0 | 0000 |
| 1 | One-hot (winner) |
| 2+ | 0000 (tie) |
1from safetensors.torch import load_file
2import torch
3
4w = load_file('model.safetensors')
5
6def wta(inputs):
7 inp = torch.tensor([float(x) for x in inputs])
8 return [int((inp * w[f'y{i}.weight']).sum() + w[f'y{i}.bias'] >= 0)
9 for i in range(4)]
10
11print(wta([0,1,0,0])) # [0, 1, 0, 0] - x1 wins
12print(wta([1,1,0,0])) # [0, 0, 0, 0] - tiethreshold-winnertakeall/
├── model.safetensors
├── model.py
├── config.json
└── README.md