threshold-reverse8

8-bit bit reversal. Reverses the order of bits.

Function

reverse8(a7, a6, a5, a4, a3, a2, a1, a0) = [a0, a1, a2, a3, a4, a5, a6, a7]

Examples

Input Output
10000000 00000001
00000001 10000000
10101010 01010101
11110000 00001111

Architecture

Single layer with 8 neurons, each copying one input bit to its reversed position.

Output Copies from Weights Bias
y0 a7 [1,0,0,0,0,0,0,0] -1
y1 a6 [0,1,0,0,0,0,0,0] -1
y2 a5 [0,0,1,0,0,0,0,0] -1
y3 a4 [0,0,0,1,0,0,0,0] -1
y4 a3 [0,0,0,0,1,0,0,0] -1
y5 a2 [0,0,0,0,0,1,0,0] -1
y6 a1 [0,0,0,0,0,0,1,0] -1
y7 a0 [0,0,0,0,0,0,0,1] -1

Parameters

Inputs 8
Outputs 8
Neurons 8
Layers 1
Parameters 16
Magnitude 16

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def reverse8(a7, a6, a5, a4, a3, a2, a1, a0):
    inp = torch.tensor([float(a7), float(a6), float(a5), float(a4),
                        float(a3), float(a2), float(a1), float(a0)])
    return [int((inp @ w[f'y{i}.weight'].T + w[f'y{i}.bias'] >= 0).item())
            for i in range(8)]

print(reverse8(1, 0, 0, 0, 0, 0, 0, 0))  # [0, 0, 0, 0, 0, 0, 0, 1]

License

MIT

Downloads last month
15
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/threshold-reverse8