Reverse engineering a neural network's clever solution to binary addition (2023)

cprimozic.net

85 points by Ameo 7 days ago


xg15 - 2 days ago

This is really cool and I hope there will be more experiments like this.

My takeaway is also that we don't really have a good intuition yet how the internal representations of neuronal networks "work" or what kind of internal representations can even be learned through SGD+backpropagation. (And also how those representations depend on the architecture)

Like in this case, where the author first imagined the network would learn a logic network, but the end result was more like an analog circuit.

It's possible to construct the "binary adder" network the author imagined "from scratch" by handpicking the weights. But the question would be interesting if it could also be learned or if SGD would always produce an "analog" solution like this one.

bob1029 - 2 days ago

> While playing around with this setup, I tried re-training the network with the activation function for the first layer replaced with sin(x) and it ends up working pretty much the same way.

There is some evidence that the activation functions and weights can be arbitrarily selected assuming you have a way to evolve the topology of the network.

https://arxiv.org/abs/1906.04358

IlikeKitties - 3 days ago

>As I mentioned, before, I had imagined the network learning some fancy combination of logic gates to perform the whole addition process digitally, similarly to how a binary adder operates. This trick is yet another example of neural networks finding unexpected ways to solve problems.

My intuition is that this solution allows for some form of gradient approach to a solution, which is why it's unintuitive. We think about solutions as all or nothing and look for complete solutions.

anon291 - 2 days ago

Very nice. I think people don't appreciate enough the correspondence between linear algebra, differential equations, and wave behavior.

Roughly speaking, it seems the network is essentially converting binary digits to orthogonal basis functions and then manipulating those basis functions. Finally a linear transformation back into the binary digit space.

bgnn - 2 days ago

The second step, passing the analog output through shifted tanh functions, is implementing an analog to digital converter (ADC). This type ADCs were common back in the BJT days.

So: DAC + sum in analog domain+ ADC is what the NN is doing.

krbaccord94f - 2 days ago

Binary layer functions, whether for DACs which convert 4-bit or 8-bit inputs to a unitary neuron allows the network to both sum the inputs as well as convert the sum to analog all within a single layer ... [to] do it all before any [Ameo] activation functions even come into play." This is sin⁻¹(tan)x in the absence of asymptote.

drougge - 3 days ago

This seems interesting, but I got stuck fairly early on when I read "all 32,385 possible input combinations". There are two 8 bit numbers, 16 totally independent bits. That's 65_536 combinations. 32_285 is close to half that, but not quite. Looking at it in binary it's 01111110_10000001, i.e. two 8 bit words that are the inverse of each other. How was this number arrived at, and why?

Looking later there's also a strange DAC that gives the lowest resistance to the least significant bit, thus making it the biggest contributor to the output. Very confusing.

rnhmjoj - 3 days ago

Original submission: https://news.ycombinator.com/item?id=34399142

YeGoblynQueenne - 2 days ago

>> I created training data by generating random 8-bit unsigned integers and adding them together with wrapping.

So, binary addition in [0,256] (base 10). Did the author try the trained network on numbers outside the training range?

It's one thing to find that your neural net discovered this one neat trick for binary addition with 8-bit numbers, and something completely different to find that it figured out binary addition in the general case.

How hard the latter would be... depends. What were the activation functions? E.g. it is quite possible to learn how to add two (arbitrary, base-10) integers with a simple regression for no other reason than regression being itself based on addition (ok, summation).