Batch size × clauses on MNIST¶
How large can a mini-batch be before accuracy suffers, and does a larger batch save time? This page answers that for three models on MNIST, over batch sizes 1 to 1024 and 1,000 to 64,000 clauses per class: 128 runs on torchtsetlin 0.7.1, one NVIDIA RTX 3090.
- Flat:
TsetlinMachine, pixel > 75, unweighted,s = 10,T = 50at 2,000 clauses. - Conv 2D:
ConvTsetlinMachine, pixel ≥ 75, 10×10 window, weighted,s = 5,T = 5000at 2,000 clauses. - Conv 3D:
Conv3dTsetlinMachineover the eight bit planes of each pixel, 8×10×10 window, samesandTas Conv 2D.
T grows in proportion to the clause count. Training uses 50,000 images and stops when the
accuracy on the remaining 10,000 has not improved for 25 epochs (at least 30, at most 500).
Every cell is one seed, so differences of a few tenths of a point between neighbouring
cells are noise.
Accuracy and time at a glance¶
Left: test accuracy at the best validation epoch. Right: GPU hours until that epoch. The stronger the colour, the higher the value; the accuracy colour scales are clipped at the value given in each title.

What the grid shows¶
- Batches of 16 to 64 are both the most accurate and the cheapest setting. This is the range the batching page recommends.
- Conv 2D reaches 99.02–99.29 % at every clause count for batches up to 64, 98.82–99.10 % at 256 and 98.44–98.96 % at 1024.
- Conv 3D degrades faster: 98.83–99.12 % at batches 1 and 32, 97.65–98.46 % at 256 and 96.75–97.94 % at 1024.
- Flat shows no clear trend up to a batch of 512 (96.02–98.11 %) and fails at 1024 (70.95–81.10 %).
- A large batch does not save time, because it needs more epochs. With 64,000 clauses, Conv 2D takes 14.1 GPU hours to its best epoch at batch 1024 and 1.75 at batch 16.
- Single-example batches are the slowest way to the same accuracy: the flat model with 64,000 clauses needs 13.9 hours at batch 1 and 1.35 at batch 16.
- More clauses buy little on MNIST: for every model, the best cell is at most 0.48 points above the best cell of its 1,000-clause row.
Time against error¶
One point per run; lower left is better. The line joins the runs that no other run beats on both time and error, labelled with batch size and clause count.

Tables¶
Flat TM¶
Test accuracy (%) at the best validation epoch:
| clauses per class | batch 1 | batch 16 | batch 32 | batch 64 | batch 128 | batch 256 | batch 512 | batch 1024 |
|---|---|---|---|---|---|---|---|---|
| 1,000 | 97.63 | 97.46 | 97.14 | 97.21 | 96.83 | 97.39 | 97.62 | 70.95 |
| 2,000 | 97.75 | 97.82 | 97.69 | 97.17 | 97.13 | 97.36 | 97.70 | 73.98 |
| 4,000 | 97.86 | 97.78 | 97.75 | 97.33 | 97.05 | 97.33 | 97.95 | 73.71 |
| 8,000 | 97.81 | 97.87 | 97.68 | 97.52 | 97.10 | 97.61 | 97.07 | 74.76 |
| 16,000 | 97.77 | 97.91 | 97.88 | 97.59 | 97.42 | 97.35 | 96.02 | 76.74 |
| 32,000 | 97.81 | 98.00 | 97.83 | 97.55 | 97.30 | 97.21 | 98.11 | 75.34 |
| 64,000 | 97.98 | 97.98 | 97.92 | 97.35 | 96.92 | 97.82 | 96.85 | 81.10 |
GPU hours to the best epoch:
| clauses per class | batch 1 | batch 16 | batch 32 | batch 64 | batch 128 | batch 256 | batch 512 | batch 1024 |
|---|---|---|---|---|---|---|---|---|
| 1,000 | 0.49 | 0.03 | 0.01 | 0.01 | 0.01 | 0.02 | 0.02 | 0.00 |
| 2,000 | 0.55 | 0.07 | 0.04 | 0.01 | 0.01 | 0.04 | 0.02 | 0.01 |
| 4,000 | 1.38 | 0.09 | 0.07 | 0.02 | 0.02 | 0.06 | 0.07 | 0.00 |
| 8,000 | 2.93 | 0.13 | 0.06 | 0.12 | 0.04 | 0.13 | 0.05 | 0.01 |
| 16,000 | 1.80 | 0.48 | 0.30 | 0.16 | 0.10 | 0.19 | 0.06 | 0.00 |
| 32,000 | 5.78 | 0.78 | 0.23 | 0.23 | 0.93 | 0.38 | 0.71 | 0.01 |
| 64,000 | 13.9 | 1.35 | 1.60 | 2.45 | 1.05 | 0.93 | 0.53 | 0.75 |
Conv 2D TM¶
Test accuracy (%) at the best validation epoch:
| clauses per class | batch 1 | batch 16 | batch 32 | batch 64 | batch 128 | batch 256 | batch 512 | batch 1024 |
|---|---|---|---|---|---|---|---|---|
| 1,000 | 99.29 | 99.21 | 99.02 | 99.05 | 98.96 | 98.82 | 98.74 | 98.44 |
| 2,000 | 99.18 | 99.17 | 99.15 | 99.08 | 99.11 | 98.93 | 98.81 | 98.54 |
| 4,000 | 99.15 | 99.17 | 99.12 | 99.20 | 99.16 | 98.98 | 98.80 | 98.71 |
| 8,000 | 99.24 | 99.22 | 99.14 | 99.16 | 99.13 | 99.10 | 98.90 | 98.74 |
| 16,000 | 99.24 | 99.16 | 99.20 | 99.14 | 99.07 | 99.05 | 98.83 | 98.88 |
| 32,000 | 99.20 | 99.24 | 99.14 | 99.21 | 99.21 | 99.10 | 98.97 | 98.81 |
| 64,000 | 99.13 | 99.21 | 99.22 | 99.20 | 99.19 | 99.03 | 98.94 | 98.96 |
GPU hours to the best epoch:
| clauses per class | batch 1 | batch 16 | batch 32 | batch 64 | batch 128 | batch 256 | batch 512 | batch 1024 |
|---|---|---|---|---|---|---|---|---|
| 1,000 | 0.61 | 0.05 | 0.02 | 0.04 | 0.07 | 0.08 | 0.20 | 0.09 |
| 2,000 | 0.25 | 0.11 | 0.08 | 0.07 | 0.15 | 0.33 | 0.32 | 0.22 |
| 4,000 | 0.65 | 0.13 | 0.06 | 0.09 | 0.18 | 0.48 | 0.37 | 0.43 |
| 8,000 | 0.96 | 0.34 | 0.14 | 0.31 | 0.30 | 1.02 | 0.99 | 1.16 |
| 16,000 | 1.93 | 0.50 | 0.51 | 0.45 | 1.25 | 2.33 | 1.40 | 2.61 |
| 32,000 | 5.13 | 1.04 | 1.00 | 2.50 | 4.00 | 3.30 | 4.18 | 4.21 |
| 64,000 | 2.16 | 1.75 | 4.48 | 3.96 | 6.03 | 5.95 | 8.35 | 14.1 |
Conv 3D TM (bit planes)¶
Test accuracy (%) at the best validation epoch:
| clauses per class | batch 1 | batch 32 | batch 256 | batch 1024 |
|---|---|---|---|---|
| 1,000 | 98.83 | 98.93 | 97.65 | 96.78 |
| 2,000 | 99.05 | 98.97 | 98.25 | 97.94 |
| 4,000 | 99.12 | 98.96 | 98.39 | 96.75 |
| 8,000 | 99.05 | 98.97 | 98.46 | 96.98 |
GPU hours to the best epoch:
| clauses per class | batch 1 | batch 32 | batch 256 | batch 1024 |
|---|---|---|---|---|
| 1,000 | 0.86 | 0.25 | 0.26 | 0.55 |
| 2,000 | 1.34 | 0.27 | 0.78 | 1.77 |
| 4,000 | 2.58 | 0.45 | 2.43 | 2.14 |
| 8,000 | 2.80 | 1.46 | 4.25 | 5.47 |
Controls¶
Fixed T. The same models with T kept at its 2,000-clause value instead of scaled (the scaled grid cell is in brackets):
| model | clauses per class | batch | test accuracy (%) |
|---|---|---|---|
| Flat TM | 16,000 | 1 | 96.36 (97.77) |
| Flat TM | 16,000 | 32 | 96.55 (97.88) |
| Flat TM | 16,000 | 256 | 96.89 (97.35) |
| Flat TM | 64,000 | 1 | 95.31 (97.98) |
| Flat TM | 64,000 | 32 | 96.57 (97.92) |
| Flat TM | 64,000 | 256 | 97.00 (97.82) |
| Conv 2D TM | 16,000 | 1 | 99.22 (99.24) |
| Conv 2D TM | 16,000 | 32 | 99.23 (99.20) |
| Conv 2D TM | 16,000 | 256 | 99.13 (99.05) |
| Conv 2D TM | 64,000 | 1 | 99.24 (99.13) |
| Conv 2D TM | 64,000 | 32 | 99.18 (99.22) |
| Conv 2D TM | 64,000 | 256 | 99.06 (99.03) |
With a fixed T the flat model loses 0.46 to 2.67 points in every cell, while Conv 2D stays within 0.11 points.
Sequential mode. The exact per-example algorithm (feedback_mode="sequential"), with the batch-1 grid cell in brackets:
| model | clauses per class | test accuracy (%) |
|---|---|---|
| Flat TM | 2,000 | 97.75 (97.75) |
| Flat TM | 16,000 | 97.88 (97.77) |
| Conv 2D TM | 2,000 | 99.16 (99.18) |
| Conv 2D TM | 16,000 | 99.20 (99.24) |
Reading the last epoch instead of the best validation epoch changes no Conv 2D cell by more than 0.19 points and no Conv 3D cell by more than 0.30. The flat model is less stable at its last epoch: it differs by up to 1.72 points for batches up to 512, and 57.31–79.10 % at 1024.
Where the numbers come from¶
Every number and figure on this page is generated from the run records of the experiment (one JSON record per run, with its command line, seed, library version and per-epoch log). The harness and the records are kept in the maintainers' research repository, not in the package.