{"id":77,"date":"2025-08-28T00:15:14","date_gmt":"2025-08-27T22:15:14","guid":{"rendered":"https:\/\/mlatilikzsolt.hu\/?p=77"},"modified":"2025-09-06T18:44:38","modified_gmt":"2025-09-06T16:44:38","slug":"intro-to-neural-networks_part2","status":"publish","type":"post","link":"https:\/\/mlatilikzsolt.hu\/en\/2025\/08\/28\/intro-to-neural-networks_part2\/","title":{"rendered":"Introduction to the World of Neural Networks Part 2"},"content":{"rendered":"<p>In the <a href=\"https:\/\/mlatilikzsolt.hu\/en\/2025\/08\/25\/intro-to-neural-networks_part1\/\" data-type=\"post\" data-id=\"61\">previous<\/a> article, we introduced the basic idea of neural networks and saw that an artificial neuron is a simplified version of the brain\u2019s nerve cells. Now let\u2019s take a closer look at how a biological neuron works and how we can model it in a computer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0-hogyan-m%C5%B1k%C3%B6dik-egy-neuron\">How Does a Neuron Work?<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-agyi-neuron\">The Biological Neuron<\/h3>\n\n\n\n<p>Without going into too much scientific detail, a biological neuron is made up of four main parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dendrites: it receives information from other neurons through these.<\/li>\n\n\n\n<li>Cell body (Soma): this processes the signals received by the dendrites.<\/li>\n\n\n\n<li>Axon: the neuron sends (or not) the processed signal through this.<\/li>\n\n\n\n<li>Axon terminals: the branches of the axon through which other neurons perceive the output signal.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"405\" src=\"https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/Neuron.webp\" alt=\"\" class=\"wp-image-79\" srcset=\"https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/Neuron.webp 720w, https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/Neuron-300x169.webp 300w, https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/Neuron-18x10.webp 18w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/figure>\n\n\n\n<p>So, the cell body receives signals from other neurons through the dendrites, processes them, and if the signal resulting from the processing reaches a certain level, the neuron \"fires\", i.e. sends a signal through the axon to the other neurons connected to it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-mesters%C3%A9ges-neuron\">Artificial Neuron<\/h3>\n\n\n\n<p>The artificial neuron attempts to mimic this operation mathematically. Its most important parts are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Inputs: these simulate the dendrites, through which the neuron receives data.<\/li>\n\n\n\n<li>Weights: each input has a weight that shows how much the data arriving at the given input influences the output value.<\/li>\n\n\n\n<li>Bias: an offset is added to the weighted sum of the input signals, which can also influence the output result.<\/li>\n\n\n\n<li>Activation function: this makes the decision as to what value should be output by the neuron (\"fire\" or not) based on the previously summarized data.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"850\" height=\"492\" src=\"https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/artificial-neuron.png\" alt=\"\" class=\"wp-image-82\" srcset=\"https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/artificial-neuron.png 850w, https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/artificial-neuron-300x174.png 300w, https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/artificial-neuron-768x445.png 768w, https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/artificial-neuron-18x10.png 18w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-matematikai-form%C3%A1ban\">In Mathematical Form<\/h4>\n\n\n\n<p>Let the inputs be in order <strong>x<sub>1<\/sub>, x<sub>2<\/sub>&#8230;x<sub>n<\/sub><\/strong>, their corresponding weights <strong>w<sub>1<\/sub>, w<sub>2<\/sub>&#8230;w<sub>n<\/sub><\/strong>, and the bias <strong>b<\/strong>. The operation performed by the neuron is as follows:<\/p>\n\n\n\n<div class=\"wp-block-katex-display-block katex-eq\" data-katex-display=\"true\"><pre>z=w_1 \\cdot x_1 + w_2 \\cdot x_2 + \\ldots + w_n \\cdot x_n + b<\/pre><\/div>\n\n\n\n<p>The activation function receives the value of <strong>z<\/strong> calculated in this way. In this case, let's take a simple <em>step<\/em> function that examines the input value and if it is zero or greater, it outputs 1, and if it is less than zero, it outputs 0.<\/p>\n\n\n\n<div class=\"wp-block-katex-display-block katex-eq\" data-katex-display=\"true\"><pre>y=\\begin{cases} 1 &amp; \\text{ha } z \\geq 0 \\\\ 0 &amp; \\text{ha } z &lt; 0 \\end{cases}<\/pre><\/div>\n\n\n\n<p>There are many types of activation functions (e.g. <em>Sigmoid, ReLU, tanh<\/em>), which we will discuss in a separate section later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-python-p%C3%A9lda\">Python Example<\/h2>\n\n\n\n<p>Let's see how to program a neuron in Python:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Bemenetek \u00e9s s\u00falyok\ninputs = &#91;0.5, 0.8&#93;     # k\u00e9t bemenet\nweights = &#91;0.4, 0.7&#93;    # hozz\u00e1juk tartoz\u00f3 s\u00falyok\nbias = -0.5             # eltol\u00e1s\n\n# Bemeneti \u00e9rt\u00e9kek \u00f6sszegz\u00e9se\nsum = (inputs&#91;0&#93;*weights&#91;0&#93; + inputs&#91;1&#93;*weights&#91;1&#93; + bias) # 0.26\n\n# Kimenet sz\u00e1m\u00edt\u00e1sa a step f\u00fcggv\u00e9nnyel\noutput = 1 if sum >= 0 else 0\n\nprint(\"A neuron kimenete:\", output) # 1<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #008000\"># Inputs and weights<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">inputs = &#91;<\/span><span style=\"color: #098658\">0.5<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #098658\">0.8<\/span><span style=\"color: #000000\">&#93;     <\/span><span style=\"color: #008000\"># two inputs<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">weights = &#91;<\/span><span style=\"color: #098658\">0.4<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #098658\">0.7<\/span><span style=\"color: #000000\">&#93;    <\/span><span style=\"color: #008000\"># their associated weights<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">bias = -<\/span><span style=\"color: #098658\">0.5<\/span><span style=\"color: #000000\">             <\/span><span style=\"color: #008000\"># bias<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #008000\"># Summarize input values<\/span><\/span>\n<span class=\"line\"><span style=\"color: #795E26\">sum<\/span><span style=\"color: #000000\"> = (inputs&#91;<\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">&#93;*weights&#91;<\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\">&#93; + inputs&#91;<\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\">&#93;*weights&#91;<\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\">&#93; + bias) <\/span><span style=\"color: #008000\"># 0.26<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #008000\"># Calculating output with the step function<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">output = <\/span><span style=\"color: #098658\">1<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #AF00DB\">if<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #795E26\">sum<\/span><span style=\"color: #000000\"> &gt;= <\/span><span style=\"color: #098658\">0<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #AF00DB\">else<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">0<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #795E26\">print<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">\"Output of the neuron:\"<\/span><span style=\"color: #000000\">, output) <\/span><span style=\"color: #008000\"># 1<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Next Article<\/h2>\n\n\n\n<p>In the next article, we will connect multiple neurons together and see how a simple <strong>layer<\/strong> is built. This will bring us closer to a complete neural network.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Az el\u0151z\u0151 r\u00e9szben megismerkedt\u00fcnk a neur\u00e1lis h\u00e1l\u00f3zatok alapgondolat\u00e1val, \u00e9s l\u00e1ttuk, hogy a mesters\u00e9ges neuron az agy idegsejtjeinek egyszer\u0171s\u00edtett m\u00e1solata. Most n\u00e9zz\u00fck meg kicsit r\u00e9szletesebben, hogyan m\u0171k\u00f6dik egy biol\u00f3giai neuron, \u00e9s hogyan modellezz\u00fck ezt a sz\u00e1m\u00edt\u00f3g\u00e9pben.<\/p>","protected":false},"author":1,"featured_media":162,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3,"footnotes":""},"categories":[9,8],"tags":[11,10,13],"class_list":["post-77","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-artificial_intelligence","category-neural-networks","tag-artificial-intelligence","tag-neural-networks","tag-python"],"featured_image_src":"https:\/\/mlatilikzsolt.hu\/wp-content\/uploads\/2025\/08\/background-7513727_640.jpg","author_info":{"display_name":"MlatilikZsolt","author_link":"https:\/\/mlatilikzsolt.hu\/en\/author\/mlatilikzsolt\/"},"_links":{"self":[{"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":9,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/posts\/77\/revisions\/117"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/media\/162"}],"wp:attachment":[{"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mlatilikzsolt.hu\/en\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}