threshold-3outof5 / model.py
phanerozoic's picture
Upload folder using huggingface_hub
51ec473 verified
raw
history blame contribute delete
545 Bytes
import torch
from safetensors.torch import load_file
def load_model(path='model.safetensors'):
return load_file(path)
def atleast3of5(a, b, c, d, e, weights):
inp = torch.tensor([float(a), float(b), float(c), float(d), float(e)])
return int((inp @ weights['neuron.weight'].T + weights['neuron.bias'] >= 0).item())
if __name__ == '__main__':
w = load_model()
print('3outof5 (majority5) sample outputs:')
print(f' 00011 -> {atleast3of5(0,0,0,1,1,w)}')
print(f' 00111 -> {atleast3of5(0,0,1,1,1,w)}')