threshold-binary2gray

4-bit binary to Gray code converter.

Function

binary2gray(B3, B2, B1, B0) -> (G3, G2, G1, G0)

Conversion formulas:

  • G3 = B3
  • G2 = B3 XOR B2
  • G1 = B2 XOR B1
  • G0 = B1 XOR B0

Example Conversions

Binary Gray
0000 (0) 0000
0001 (1) 0001
0010 (2) 0011
0011 (3) 0010
0100 (4) 0110
0101 (5) 0111
0110 (6) 0101
0111 (7) 0100

Architecture

Parallel XOR gates for each output bit:

B3 ─────────────────────────► G3
B3,B2 ─► [XOR] ─────────────► G2
B2,B1 ─► [XOR] ─────────────► G1
B1,B0 ─► [XOR] ─────────────► G0

Each XOR uses 3 neurons (OR, NAND, AND) with mag-7 structure.

Parameters

Inputs 4
Outputs 4
Neurons 10
Layers 2
Parameters 43
Magnitude 33

Usage

from safetensors.torch import load_file
# Full implementation in model.py

License

MIT

Downloads last month
12
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-binary2gray