Demir's first attempt at combining the feeds just crashed the console. Nazari wants it fixed, at sensor speed.
Demir's first pass at the amplifier is already on the main console when the shift starts, and so is its output: Error in matMul: inner shapes (64) and (1) of Tensors with shapes 1,64 and 1,64 and transposeA=false and transposeB=false must match. One line of code, one error, sixty-four channels of raw signal going nowhere.
Raw data is useless to me. Clean it, combine the feeds, amplify what matters. And it runs at sensor speed or it doesn't run. We take two million readings a minute. Whatever that red text is, it is not two million readings a minute.
This lesson starts where you are standing: at the bug. You'll read the error, meet the two multiplication ops it is confusing, and repair the pipeline.
Here is the code that produced it. The intent: amplify each of the 64 channels by its own gain factor. Position by position, gain times reading.
The error is precise once you can read it: matMul multiplies rows into columns, so it needs the left 's column count (64) to equal the right tensor's row count (1). But matching positions was the intent all along, and that is a different op with no inner- rule at all. TensorFlow.js has both multiplications; the bug is reaching for the wrong one.
When you write arr.map((x, i) => x + arr2[i]), you're doing element-wise addition. tf.mul, tf.add, and tf.sub are the same idea across any number of dimensions, on the GPU. gains.mul(window) is the one-word fix for the broken amplifier:
So why does matMul exist at all? Because "every row dot-producted with every column" is the operation neural networks are made of, and no chain of element-wise ops can express it. It comes with the one inflexible rule the error message was enforcing:
[m, n] × [n, p] → [m, p]: the inner dimensions must match.
The left tensor's column count must equal the right tensor's row count. When they don't, you flip one with transpose(), which swaps a tensor's rows and columns, turning [3, 2] into [2, 3]:
Why care? Every of every neural network you'll build is essentially matMul(input, weights) + bias. The shape rule above is the single most common source of errors in ML code. The error that opened this lesson will find you again the day you build your first network layer; next time you'll read it in one pass.
Add two tensors together to combine sensor readings.