logic-gate / README.md
simonko912's picture
Update README.md
c1fe3c0 verified
|
Raw History Blame Contribute Delete
778 Bytes
metadata
license: apache-2.0
language:
  - en

logic-gate

yes 102 parameters, not million, not thousand, one hundred and two. its the most useless and weirdest neural network, but can be ok for testing out stuff.

Details

Tiny 12 → 4 → 4 → 4 → 2 network that simulates 10 logic gates from one set of weights.

Input is a one-hot gate selector plus a and b. Output is 2 neurons.

Use

pip install torch safetensors
python example.py
from example import forward

print(forward("XOR", 1, 0).tolist())   # [p(out1), p(out2)]
print(forward("CNOT", 1, 0).tolist())  # [p(a), p(a XOR b)]

Gates: AND OR XOR NAND NOR XNOR NOT BUF CNOT SWAP

  • One-output gates: [result, 1 - result]
  • CNOT(a, b) = (a, a XOR b)
  • SWAP(a, b) = (b, a)