The Smallest Brain You Can Build: A Perceptron in Python
Posted by DevarshRanpara 1 day ago
Comments
Comment by romaniv 1 day ago
https://medium.com/@VictorBanev/the-simplest-learning-machin...
This is a description of a 5-line algorithm that learns and stores approximate probability of an event using just 1 byte of persistent memory.
Comment by a1o 1 day ago
Comment by DevarshRanpara 1 day ago
Comment by kzrdude 1 day ago
Comment by Lerc 1 day ago
I like the ability of this article to do the tiny training runs in browser. It makes the point of a bias clear. Too many tutorials get sucked into the proof of zero times anything is zero. Everyone knows that. What you should show is where that mstters in the problem at hand.
3blue1brown does one of the best depictions of why we need an activation function.
Karpathy's videos are a little tougher for a beginner to grasp, but excel at solving a complete problem. I knew all of the theory behind what it takes to make micrograd before I made my own by following the video, but what you get from doing it can't be understated.
It's hard to describe but it what you learn is more of a feel than pure knowledge. It gives you a better sense of knowing when the principles apply in other circumstances.
Perhaps it's the distinction of understanding how springs and gears work, then looking at a clock and understanding how the gears and springs move the hands. There's still more needed if you want to make a clock. And that stuff is what let's you also make a wind up toy.
Comment by DevarshRanpara 1 day ago
Comment by rahen 1 day ago
That was the first thing that came to mind when I read "the smallest brain you can build". Nowadays, that "small brain" would likely be built on a breadboard using op-amps instead.
Comment by Schlagbohrer 1 day ago
Comment by rahen 1 day ago
Yet we had the computational power to run backpropagation in the 1960s and small Transformers in the 1970s (I'm the author of both):
https://github.com/dbrll/Xortran (backprop on IBM 1130, 60s)
https://github.com/dbrll/ATTN-11 (Transformer on PDP-11, 70s)
What was missing wasn't the raw processing power, but the ideas and algorithms themselves. Because funding and research were completely discouraged during the AI winter, neural networks research was left dormant and we lost two decades.
Comment by WarmWash 1 day ago
Comment by mr_toad 1 day ago
They were simply too computationally expensive to train for the limited things they could do. It wasn’t until we had the ability to train large neural networks on commodity hardware that things really took off.
Comment by j_bum 1 day ago
Tl;dr - compute was the bottleneck.
I am not associated with this channel/video, just love it. I’ve shared it here before.
Comment by WarmWash 1 day ago
Comment by utopiah 1 day ago
let gravity = setInterval( _ => { if (projectile.object3D.position.y > 0) projectile.object3D.position.y \*= .99 }, 100)
Jokes aside I find that providing ridiculously short toy examples that provide the very limited foundation of a concept are extremely empowering in pedagogy. You "get" it right away because it "fits" in your mind, then you dare tinker with it and quickly see how limited it is, then get excited again. It's a powerful trick to learn more IMHO.Comment by DevarshRanpara 1 day ago
Comment by zkmon 1 day ago
Going further backwards, the transistor (or a PNP junction) is the hardware level enabler of the IF statement. The action (switching) driven by the current which in turn controls other switches, is the first manifestation of "observe and act" by inanimate things at the speed of electricity.
Mechanical equivalents existed ofcourse - speed of a governer which controls the flow of fuel which in turn controls the speed of the governer.
Comment by RetroTechie 1 day ago
Back up a bit please! Analog computing is a thing. And it isn't even new - not by a long shot.
There are good reasons why practically all computing today is the digital kind. But electronic 'equivalents' of neural nets is one area where analog might make sense. Adding inputs can be as simple as a bunch of resistors + a transistor. Even on modern silicon nodes, that might be a more efficient setup than digital inputs, N-bit adders/multipliers etc. Not saying that's the case, and AI hardware should be based on analog circuitry. But it could be, and perhaps found to be practical.
Comment by lambertsimnel 1 day ago
That's an interesting idea, but could the weights be transferred to different hardware and still work? If not, that would be a significant limitation, even if it were preferable in some cases.
Comment by mr_toad 1 day ago
Artificial neurons are significantly more complex that single transistors, and even a minimal hardwired circuit to implement just one neuron requires quite a number of transistors.
Comment by Lerc 1 day ago
It's the same thing as stimulus, response.
Unchanging in response to circumstances is static.
Changing in the absence of circumstances is randomness.
The conditional is all that remains. Changing in response to circumstances
(Arguably, unchanging in the absence of circumstances completes the truth table, but it's a whole lot of nothing)
Comment by BatteryMountain 1 day ago
Comment by tomtom1337 1 day ago
Try it, it's llama 3.1 8B at 16000 tokens per second.
chatjimmy.ai https://taalas.com/the-path-to-ubiquitous-ai/
Comment by jupr 1 day ago
Comment by mr_toad 1 day ago
Comment by rusk 1 day ago
Comment by adrian_b 1 day ago
There exist several equivalent sets of primitive operations. While the sets containing only NAND or only NOR, or both AND and NOT or both OR and NOT are more notorious, these logical operations are more abstract and they do not indicate precisely a hardware implementation, i.e. there are many distinct hardware methods to make such logical gates.
Other sets of primitive operations map directly to hardware devices, e.g. the sets of primitive operations composed of maximum and complement or of minimum and complement map directly to a hardware implementation using rectifier diodes and inverting amplifiers (which can be made with either semiconductor devices or with vacuum tubes, or also with pneumatic or hydraulic devices).
Other sets of primitive operations are obtained by replacing the maximum or minimum circuits with series or parallel connections of switches, like in the CMOS logic that is nowadays dominant.
The alternative IF expression corresponds in hardware to a 2-way multiplexer, which, together with the 2 constant functions "0" and "1" (a.k.a. "false" and "true" or "low voltage" and "high voltage"), is sufficient for a complete set of computational primitives.
Besides those mentioned above, the main remaining variant for a complete set of computational primitives consists of an analog (possibly weighted) adder and an analog comparator, which had been used in the so-called RTL circuits (resistor-transistor logic) and which also corresponds to perceptrons. RTL had been used in some early integrated circuits, before being replaced by DTL and TTL circuits (which are based on minimum and complement functions).
In hardware, e.g. in RTL circuits, a combined analog adder+comparator can be made with a single high-gain amplifying device, together with a set of weighting resistors and a bias resistor. RTL circuits can implement complex logic with fewer devices (e.g. they can implement a neural network in the analog domain), but they were replaced during the sixties of the past century with DTL, then TTL, because those were faster (in RTL, the resistors limit the charging currents for input capacitors and parasitic capacitors, which slows down the logical transitions) and the fact that they needed more devices was not important, due to the quick increase in circuit density.
Comment by lioeters 1 day ago
There's a wide variety of computational primitives, including lambda calculus, combinators, cellular automata, rewriting systems. Perhaps some are more practical to implement in hardware, particularly the kind of DIY electronics or analog machines that can also be put together from scratch. It might look like a whole building of mechanical switches, powered by a water wheel ("watermill"), for example.
Comment by coldtea 1 day ago
Comment by lioeters 1 day ago
Comment by gpderetta 1 day ago
A transistor (driven to saturation) is a much better model.
Comment by utopiah 1 day ago
Comment by ankit84 1 day ago
Comment by DevarshRanpara 1 day ago
Comment by SubiculumCode 1 day ago
import random
learning_rate = 0.1
EPOCHS = 50
NUM_INPUTS = 3
weights = [random.uniform(-1, 1) for _ in range(NUM_INPUTS)]
bias = random.uniform(-1, 1)
data = []
for _ in range(100):
inputs = [random.uniform(-1, 1) for _ in range(NUM_INPUTS)]
result = sum(inputs) > 0
data.append((inputs, result))
for epoch in range(EPOCHS):
for inputs, result in data:
weighted_sum = bias
for i in range(NUM_INPUTS):
weighted_sum += inputs[i] * weights[i]
prediction = weighted_sum > 0
if prediction != result:
error = int(result) - int(prediction)
for i in range(NUM_INPUTS):
weights[i] += learning_rate * error * inputs[i]
bias += learning_rate * error
print(f"Final weights: {[round(w, 3) for w in weights]}")
print(f"Final bias: {round(bias, 3)}")Comment by DevarshRanpara 1 day ago
Comment by trekhleb 1 day ago
I played with similar approach in JavaScript and built a NanoNeuron https://github.com/trekhleb/nano-neuron (it is more verbose than Python though)
Comment by virajk_31 1 day ago
Comment by ninalanyon 1 day ago
Or to put it another way are there any local only tools that can be trained on my own set of images to automatically tag new images? Tools that do not already have built in classes of image.
I take a lot of photographs and it would be handy to reduce the drudgery of tagging them so to say broadly what the subject was so that they are easier to find later.
Comment by Bimos 1 day ago
> In 1958, a researcher named Frank Rosenblatt built a machine *he called* the perceptron.
> It was *inspired* by a single brain cell, a neuron.
Comment by Lerc 1 day ago
I included a remark about how time travellers would find Rosenblatt a better target than Miles Dyson.
I was never quite sure on how close, or over, the line that was on appropriateness. It was definitely thought provoking.
Comment by lmf4lol 1 day ago
and its an a great learning resource - which is arguably more important :-)
Comment by esafak 1 day ago
If you don't know ML I don't think you're going to learn much through ad hoc demos.
Comment by mysterydip 1 day ago
Comment by rishabhaiover 1 day ago
Comment by andai 1 day ago
I used to have a wife, but they took her in the divorce!
The human mind isn't very good at correlating its contents[0]. You can "know" something for years without realizing its implications.
The human mind traverses its knowledge like a man with a small flashlight in total darkness. Our beam of attention is small and narrow, so you need to put the right things in it, or the magic doesn't happen.
This has important implications for learning. I don't know what they are though.
Probably something like, "you can know something without knowing what it means." You haven't connected it to the things it's supposed to be connected to yet. I don't know how to fix that though. (Something involving the Feynman technique, maybe?)
[0] H.P. Lovecraft quote - https://www.goodreads.com/quotes/193944-the-most-merciful-th...
Comment by llimllib 1 day ago
(before numarray and numpy merged!)
Comment by stuxnet79 1 day ago
EDIT: His son is co-author?
Comment by zxexz 1 day ago
I think those down voting you are perhaps overly eager. I upvoted. Grab "Deep Learning" - you'll find it useful, imteresting, and likely less 'dense' in the negative sense!
Comment by stuxnet79 1 day ago
> Grab "Deep Learning" - you'll find it useful, imteresting, and likely less 'dense' in the negative sense!
Absolutely! I just ordered it and it's enroute :)
Comment by DevarshRanpara 1 day ago
Comment by warengonzaga 1 day ago
Comment by CyberDildonics 1 day ago
Comment by opem 1 day ago
Comment by DevarshRanpara 1 day ago
Comment by techteach00 1 day ago
Comment by charcircuit 1 day ago
f(x) = 0.
Comment by rippeltippel 1 day ago
Comment by jeffwass 1 day ago
Comment by lioeters 1 day ago
Ix = x
Kxy = x
Sxyz = xz(yz)Comment by opem 1 day ago
Comment by charcircuit 23 hours ago
Comment by moffkalast 1 day ago
Comment by vain 1 day ago
Comment by DevarshRanpara 1 day ago
Comment by kgwxd 1 day ago
Comment by moi2388 1 day ago
Comment by knightops_dev 1 day ago
Comment by sspoisk 1 day ago
Comment by infoinlet 1 day ago
Comment by jkwang 1 day ago
Comment by haeseong 1 day ago
Comment by EvanXue 1 day ago
Comment by karinatran 1 day ago
Comment by hbwang2076 1 day ago
Comment by b33j0r 1 day ago
Comment by andblac 1 day ago
Comment by Waterluvian 1 day ago