threshold-nor3 / model.py
phanerozoic's picture
Upload folder using huggingface_hub
adc776c verified
raw
history blame contribute delete
550 Bytes
import torch
from safetensors.torch import load_file
def load_model(path='model.safetensors'):
return load_file(path)
def nor3(a, b, c, weights):
"""3-input NOR gate."""
inp = torch.tensor([float(a), float(b), float(c)])
return int((inp * weights['weight']).sum() + weights['bias'] >= 0)
if __name__ == '__main__':
w = load_model()
print('3-input NOR truth table:')
for a in [0, 1]:
for b in [0, 1]:
for c in [0, 1]:
print(f'NOR({a},{b},{c}) = {nor3(a, b, c, w)}')