import torch from safetensors.torch import load_file def load_model(path='model.safetensors'): return load_file(path) def or3(a, b, c, weights): """3-input OR 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 OR truth table:') for a in [0, 1]: for b in [0, 1]: for c in [0, 1]: print(f'OR({a},{b},{c}) = {or3(a, b, c, w)}')