File size: 545 Bytes
82d5619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)}')