Repository navigation
v18.6 — Lookup tables that hold across the whole format, logit-ranked classifiers, and a wider ONNX importer
Latestv18.6 — Lookup tables that hold across the whole format, logit-ranked classifiers, and a wider ONNX importer
Fixes
- The exp table no longer wraps in narrow formats (#288). The table generator converted each value straight to the table's storage type, which wrapped when the format could not hold it. In Q8.8 the last nine exp entries were garbage, so exp(5.0) came out negative; the same overflow hit every format with fewer than 10 integer bits, stored cos(0) as -1 in every Q1 format and overflowed log in the Q1 and Q2 formats. Entries now saturate, and every in-range entry is unchanged.
- log, sin and cos reduce their input instead of clamping it (#291, fixes #289 and #290). These three used the same 96-knot table over [-6, 6) as the activations. log interpolated every input below 0.125 toward 0, so the cross-entropy loss fell as a prediction became more confidently wrong (0.166 at p = 0.01 instead of 4.605), and sin and cos returned the value at 5.875 for every input of 6 or more. The new
cpp/lookupFunctions.hppwrites x as m * 2^e and reads log(m) from a 65-entry table over [1, 2], and it reduces sin and cos by pi/2 into a 65-entry quarter-wave table. In Q16.16, log is within 8e-5 ofstd::logfor every positive input, and sin and cos are within 1.2e-4 ofstd::sinandstd::cosover the whole range of the format.CrossEntropyLossCalculatorand the fixed-point dual numbers use them.
New features
getPredictedClass()ranks classifier outputs by their logits (#293). The fixed-point sigmoid table is flat beyond ±6, so confident outputs tie there and an argmax overgetLearnedValues()can only pick the first of them.NeuralNetwork::getOutputPreActivations()returns the output layer's logits, bit-exact with what the layer computed and at no extra memory, andgetPredictedClass()returns their argmax. Thegas_sensor_drift,iris,optical_digitsandhar_activityexamples now use it. Over 10 seeds,gas_sensor_drift's batch-10 accuracy rises from 0.726 to 0.766 and improves on every seed;optical_digitsimproves slightly, andirisandhar_activityare unchanged.- The ONNX importer covers residual CNNs (#286). It now maps depthwise convolution to
QDepthwiseConv2D,MaxPooltoQMaxPool2D, average and global average pooling to aQDepthwiseConv2Dthat averages and changes grid in one rounding, a residualAddtoQAdd, andQLinearSoftmaxto a softmax record. A new layer-graph check refuses a model in which a layer reads a tensor in a different grid from the one the previous layer wrote, which used to import silently and compute something else, and each record lists the layers it reads. This was contributed as a patch from the tinymind-rs port of the importer.
Removed
- The 128-bit lookup tables (#292, fixes #287). They did not compile, and no format could read them, since
QValuecaps a format at 64 bits. The sixcpp/*Values128Bit.hppheaders are deleted, andcpp/lookupTables.cppshrinks from about 145,000 lines to 59,000. All 8- to 64-bit tables are byte-identical.
Upgrade notes
- log, sin and cos now return different, correct values outside the old table range, and the log and trig tables hold 65 entries instead of 96. Cross-entropy losses reported during training change accordingly.
- Code that included a
*Values128Bit.hppheader directly no longer compiles; no build could have used those tables.
Docs
docs/activation-luts.mddescribes saturation, the log and trig table layout and the table sizes;docs/neural-networks.mdexplains how to pick a class; the README and the Pages index give the real 64-bit format ceiling and the table sizes (#294).
Documentation, architecture guides, and example gallery: https://danmcleran.github.io/tinymind/
Full changelog: v18.5...v18.6