--- license: mit tags: - pytorch - safetensors - threshold-logic - neuromorphic --- # threshold-nor4 4-input NOR gate. Outputs 1 only when all inputs are 0. ## Circuit ``` x1 x2 x3 x4 │ │ │ │ └───┴───┴───┘ │ ▼ ┌──────────┐ │w:-1,-1,-1,-1│ │ b: 0 │ └──────────┘ │ ▼ NOR4(x1,x2,x3,x4) ``` ## Parameters | | | |---|---| | Weights | [-1, -1, -1, -1] | | Bias | 0 | | Magnitude | 4 | ## Optimality Exhaustive enumeration of 681 configurations confirms magnitude 4 is optimal. 1 valid configuration exists. | Magnitude | Valid Configs | |-----------|---------------| | 0-3 | 0 | | 4 | 1 | ## Usage ```python from safetensors.torch import load_file import torch w = load_file('model.safetensors') def nor4(x1, x2, x3, x4): inputs = torch.tensor([float(x1), float(x2), float(x3), float(x4)]) return int((inputs * w['weight']).sum() + w['bias'] >= 0) ``` ## License MIT