threshold-lessthanorequal

1-bit less-than-or-equal comparator. Outputs 1 when a <= b.

Function

lte(a, b) = 1 if a <= b, else 0

Equivalent to: NOT(a) OR b (implication)

Truth Table

a b a <= b
0 0 1
0 1 1
1 0 0
1 1 1

Architecture

Single neuron: weights [-1, 1], bias 0

Fires when: -a + b >= 0, i.e., b >= a

Parameters

Inputs 2
Outputs 1
Neurons 1
Layers 1
Parameters 3
Magnitude 2

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def lte(a, b):
    inp = torch.tensor([float(a), float(b)])
    return int((inp @ w['neuron.weight'].T + w['neuron.bias'] >= 0).item())

print(lte(0, 1))  # 1
print(lte(1, 0))  # 0

License

MIT

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

Collection including phanerozoic/threshold-lessthanorequal