Artificial neural networks in simple words

  • Brain
  • When, over a bottle of beer, I started talking about neural networks, people usually began to look at me fearfully, became sad, sometimes their eyes began to twitch, and in extreme cases they crawled under the table. But in fact, these networks are simple and intuitive. Yes Yes exactly! And let me prove it to you!

    Let's say I know two things about a girl - whether I like her or not, and whether there is anything I can talk to her about. If there is, then we will consider it one, if not, then we will consider it zero. Let's take a similar principle for appearance. Question: “Which girl will I fall in love with and why?”


    You can think simply and uncompromisingly: “If she’s pretty and has something to talk about, then I’ll fall in love. If it’s neither one nor the other, then quit.”



    But what if I like the lady, but there’s nothing to talk about with her? Or vice versa?


    It is clear that for each of us one thing will be more important. More precisely, each parameter has its level of importance, or rather, weight. If you multiply the parameter by its weight, you get, respectively, “the influence of appearance” and “the influence of talkativeness.”


    And now I can answer my question with a clear conscience:


    “If the influence of charisma and the influence of talkativeness in total is greater than the value of “amorousness”, then I will fall in love...”



    That is, if I put a large weight on a lady’s “talkability” and a small weight on her appearance, then in a controversial situation I will fall in love with a person with whom it is pleasant to chat. And vice versa.



    Actually, this rule is the neuron.


    An artificial neuron is a function that transforms several input facts into one output. By adjusting the weights of these facts, as well as the excitation threshold, we adjust the adequacy of the neuron. In principle, for many, the science of life ends at this level, but this story is not about us, right?


    Let's draw a few more conclusions:

    • If both weights are small, then it will be difficult for me to fall in love with anyone.
    • If both weights are too large, then I will fall in love with a pillar.
    • You can also make me fall in love with a pillar by lowering the threshold of falling in love, but please don’t do this to me! Let's just forget about him for now, okay?

    Speaking of threshold

    It’s funny, but the “amorousness” parameter is called the “excitation threshold.” But, so that this article does not receive an “18+” rating, let’s agree to simply say “threshold,” okay?

    Neural network

    There are no uniquely attractive and uniquely sociable ladies. And falling in love is different from falling in love, no matter what anyone says. Therefore, instead of the brutal and uncompromising “0” and “1”, let’s use percentages. Then you can say - “I’m very much in love (80%), or “this lady is not very talkative (20%).”


    Our primitive “neuron-maximalist” from the first part is no longer suitable for us. It is being replaced by a “sage neuron”, the result of which will be a number from 0 to 1, depending on the input data.



    “Neuron Sage” can tell us: “this lady is quite beautiful, but I don’t know what to talk to her about, so I don’t really admire her.”



    Some terminology

    By the way, the input facts of a neuron are called synapses, and the output proposition is called an axon. Connections with a positive weight are called excitatory, and those with a negative weight are called inhibitory. If the weight is zero, then it is considered that there is no connection (dead connection).


    Let's move on. Let's make another assessment based on these two facts: how good is it to work (cooperate) with such a girl? We will act in exactly the same way - add a wise neuron and adjust the weights in a way that is comfortable for us.


    But judging a girl based on two characteristics is very rude. Let's judge her by three! Let's add one more fact - money. Which will range from zero (absolutely poor) to one (Rockefeller's daughter). Let's see how our judgments change with the arrival of money...


    For myself, I decided that, in terms of charm, money is not very important, but a chic look can still influence me, so I will make the weight of money small but positive.


    In my work, I absolutely don’t care how much money a girl has, so I’ll make the weight equal to zero.



    Evaluating a girl only for work and falling in love is very stupid. Let's add how pleasant it will be to travel with her:

    • Charisma in this task is neutral (zero or low weight).
    • Being talkative will help us (positive weight).
    • When the money runs out in real travel, the drive really begins, so I will make the weight of money slightly negative.

    Let's combine all these three schemes into one and find that we have moved to a deeper level of judgment, namely: from charisma, money and talkativeness - to admiration, cooperation and the comfort of traveling together. And note - these are also signals from zero to one. This means that now I can add the final “maximalist neuron”, and let it unambiguously answer the question - “to marry or not”?



    Okay, of course, not everything is so simple (in terms of women). Let's bring a little drama and reality into our simple and rainbow world. First, let’s make the “will I marry or not marry” neuron wise. Doubts are inherent in everyone, one way or another. And let’s add the “I want children from her” neuron and, to be completely honest, the “stay away from her” neuron.


    I don't understand anything about women, and that's why my primitive network now looks like the picture at the beginning of the article.


    The input judgments are called the “input layer”, the resulting ones are called the “output layer”, and the one that is hidden in the middle is called “hidden”. The hidden layer is my judgments, semi-finished products, thoughts that no one knows about. There may be several hidden layers, or there may be none.

    Down with maximalism.

    Remember when I talked about the negative impact of money on my desire to travel with a person? So, I was lying. A person who has neither little nor much money is best suited for traveling. It’s more interesting to me and I won’t explain why.


    But here I run into a problem:


    If I put the weight of money negative, then the less money, the better for travel.
    If positive, then the richer the better,
    If zero, then the money is on the side.


    I can’t do this, with just weight, to force the neuron to recognize the situation “neither more nor less”!


    To get around this, I will make two neurons - “a lot of money” and “little money”, and give them the cash flow from our lady as input.


    Now I have two judgments: “a lot” and “a little”. If both conclusions are insignificant, then it literally turns out “neither more nor less.” That is, let’s add another neuron to the output, with negative weights:



    “Not much.” Red arrows - positive connections, blue - negative ones


    In general, this means that neurons are like construction elements. Just as a processor is made from transistors, we can assemble a brain from neurons. For example, the judgment “Either rich or smart” can be made like this:



    Or or. Red arrows - positive connections, blue - negative




    you can replace “wise” neurons with “maximalists” and then we get the logical operator XOR. The main thing is not to forget to adjust the excitation thresholds.


    Unlike transistors and the uncompromising “if-then” logic of a typical programmer, a neural network can make informed decisions. Their results will change smoothly, with a smooth change in the input parameters. This is wisdom!


    Let me draw your attention to the fact that adding a layer of two neurons allowed the “neither more nor less” neuron to make a more complex and balanced judgment, to move to a new level of logic. From “a lot” or “a little” - to a compromise solution, to a deeper, from a philosophical point of view, judgment. What if we add more hidden layers? We can wrap our minds around that simple network, but what about a network that has 7 layers? Are we able to comprehend the depth of her judgment? What if each of them, including the input one, has about a thousand neurons? What do you think she's capable of?


    Imagine that I further complicated my example with marriage and falling in love, and came to such a network. Somewhere in it all nine of our neurons are hidden, and this is already more like the truth. With all the desire, it is simply impossible to understand all the dependencies and depth of judgment of such a network. For me, the transition from a 3x3 to 7x1000 network is comparable to realizing the scale, if not of the universe, then of the galaxy - relative to my height. Simply put, I can't do it. The solution of such a network, the firing of the output of one of its neurons, will be inexplicable by logic. This is what in everyday life we ​​can call “intuition” (at least “one of..”). An incomprehensible desire of the system or its hint.


    But, unlike our synthetic 3x3 example, where each neuron in the hidden layer is quite clearly formalized, in a real network this is not necessarily the case. In a well-tuned network, whose size is not excessive to solve the task at hand, each neuron will detect some feature, but this absolutely does not mean that in our language there will be a word or sentence that can describe it. If you project it onto a person, then this is some kind of characteristic of him that you feel, but cannot explain in words.

    Education.

    A few lines earlier I mentioned a well-tuned network, which probably provoked a silent question: “How can we set up a network consisting of several thousand neurons? How many “man-years” and lost lives does this require?.. I’m afraid to guess the answer to the last question. It is much better to automate this configuration process - to force the network to configure itself. This automation process is called learning. And to give a superficial idea of ​​it, I will return to the original metaphor about the “very important question”:


    We appear in this world with a pure, innocent brain and a neural network that is absolutely not tuned towards women. It needs to be properly configured somehow so that happiness and joy come into our home. To do this, we need some experience, and there are several ways to obtain it:


    1) Training with a teacher (for romantics). Watch enough of Hollywood melodramas and read tearful novels. Or watch enough of your parents and/or friends. After that, depending on the sample, go to test the acquired knowledge. After an unsuccessful attempt, repeat everything again, starting with the novels.


    2) Learning without a teacher (for desperate experimenters). Try to marry a dozen or two women at random. After every marriage, you scratch your turnips in bewilderment. Repeat until you understand that you’re tired, and you “already know how it happens.”


    3) Learning without a teacher, option 2 (the path of desperate optimists). Give up on everything, do something in life, and one day find yourself married. After this, reconfigure your network in accordance with the current reality so that everything suits you.



    All of the above is true for an artificial neural network of the “perceptron” type. Other networks are similar to it in basic principles, but have their own nuances.


    Good luck with your scales and great training samples! Well, if this is no longer necessary, then tell someone else about it.



    The weights of my neural network are not configured, and I just can’t figure out which resource this article should refer to.

    Only registered users can participate in the survey. Come in, please.