{"id":429,"date":"2026-04-30T00:00:00","date_gmt":"2026-04-29T23:00:00","guid":{"rendered":"https:\/\/kosokoking.com\/?p=429"},"modified":"2026-04-25T21:43:20","modified_gmt":"2026-04-25T20:43:20","slug":"perceptron","status":"publish","type":"post","link":"https:\/\/kosokoking.com\/index.php\/technology\/perceptron\/","title":{"rendered":"Perceptron"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You cannot meaningfully attack a system you do not understand at the component level. The perceptron is the primitive unit of every neural network. It serves as the foundation for everything from spam filters to large language models. It is a tiny decision engine and its limitations are not historical curiosities, they are the structural constraints that shaped every architecture that followed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What a perceptron actually does<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A perceptron takes a set of numerical inputs, multiplies each one by a weight, sums the results, adds a bias term, and passes the total through an activation function.The output represents a decision such as a binary choice between one and zero or the command to fire instead of remaining still.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The components, in order:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Inputs<\/strong>\u00a0(x1, x2, &#8230;, xn): numerical features. Each one represents something measurable about the data.<\/li>\n\n\n\n<li><strong>Weights<\/strong>\u00a0(w1, w2, &#8230;, wn): each input gets a weight that determines how much influence it has on the output. A large positive weight amplifies that input&#8217;s vote. A negative weight suppresses it.<\/li>\n\n\n\n<li><strong>Summation<\/strong>: the weighted inputs are combined:\u00a0<code>sum = (w1 * x1) + (w2 * x2) + ... + (wn * xn)<\/code>.<\/li>\n\n\n\n<li><strong>Bias<\/strong>\u00a0(b): a constant added to the sum. It shifts the decision threshold, allowing the perceptron to activate even when all inputs are zero.<\/li>\n\n\n\n<li><strong>Activation function<\/strong>\u00a0(f): introduces a threshold. The simplest version follows a step function logic by producing a one for any total above zero and a zero for everything else.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The entire operation collapses to one line of logic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>output = 1 if (sum(w&#91;i] * x&#91;i]) + bias) &gt; 0 else 0\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That is the whole machine. Every layer of every deep network is a variation on this theme, scaled up and stacked.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A concrete example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Abstraction is easier to follow with numbers. Consider a perceptron that decides whether to play tennis based on four weather features, each encoded as integers:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Encoding<\/th><\/tr><\/thead><tbody><tr><td>Outlook<\/td><td>Sunny = 0, Overcast = 1, Rainy = 2<\/td><\/tr><tr><td>Temperature<\/td><td>Hot = 0, Mild = 1, Cool = 2<\/td><\/tr><tr><td>Humidity<\/td><td>High = 0, Normal = 1<\/td><\/tr><tr><td>Wind<\/td><td>Weak = 0, Strong = 1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The weights and bias are predefined:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>w1 (Outlook)     =  0.3\nw2 (Temperature) =  0.2\nw3 (Humidity)     = -0.4\nw4 (Wind)         = -0.2\nbias              =  0.1\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Notice what the weights encode. Humidity and wind carry negative weights, meaning high humidity and strong wind push the output toward &#8220;don&#8217;t play.&#8221; The bias of 0.1 gives a slight default lean toward playing. These are not arbitrary numbers. In a trained model, they would be the product of an optimisation algorithm adjusting them over hundreds or thousands of examples.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now feed in a specific day: Sunny (0), Mild (1), High humidity (0), Weak wind (0).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>weighted_sum = (0.3 * 0) + (0.2 * 1) + (-0.4 * 0) + (-0.2 * 0)\n# weighted_sum = 0.2\n\ntotal = weighted_sum + 0.1\n# total = 0.3\n\noutput = 1 if 0.3 &gt; 0 else 0\n# output = 1 -&gt; Play tennis\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The perceptron says play. Change the humidity to High (encoded differently, or adjust the encoding so High = 1), and that -0.4 weight starts dragging the sum below zero. The decision flips. This is how weights create a decision boundary: a line in feature space that separates &#8220;play&#8221; from &#8220;don&#8217;t play.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In full Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def step_activation(x):\n    return 1 if x &gt; 0 else 0\n\n# Inputs\noutlook, temperature, humidity, wind = 0, 1, 0, 0\n\n# Weights and bias\nweights = &#91;0.3, 0.2, -0.4, -0.2]\ninputs = &#91;outlook, temperature, humidity, wind]\nbias = 0.1\n\n# Forward pass\nweighted_sum = sum(w * x for w, x in zip(weights, inputs))\noutput = step_activation(weighted_sum + bias)\n\nprint(f\"Decision: {'Play' if output == 1 else 'Stay home'}\")\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is a forward pass. Data enters, flows through one computation, and a decision exits the other end. Every inference call to every neural network follows this pattern, repeated across millions of parameters instead of four.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where it breaks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A single perceptron can only learn problems where the two classes can be separated by a straight line (or, in higher dimensions, a hyperplane). This constraint is called linear separability, and it is the reason a single perceptron cannot solve the XOR problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">XOR returns 1 when exactly one of two inputs is true:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Input A<\/th><th>Input B<\/th><th>XOR Output<\/th><\/tr><\/thead><tbody><tr><td>0<\/td><td>0<\/td><td>0<\/td><\/tr><tr><td>0<\/td><td>1<\/td><td>1<\/td><\/tr><tr><td>1<\/td><td>0<\/td><td>1<\/td><\/tr><tr><td>1<\/td><td>1<\/td><td>0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Plot these on a 2D grid. The 1s sit on opposite corners. No single straight line can separate them from the 0s. A perceptron, limited to drawing one line, fails completely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This limitation was identified in 1969 by Marvin Minsky and Seymour Papert in their book\u00a0<em><a href=\"https:\/\/direct.mit.edu\/books\/monograph\/3132\/PerceptronsAn-Introduction-to-Computational\" title=\"\">Perceptrons<\/a><\/em>. The publication nearly killed neural network research for a decade.  The result was the first AI winter and a period of time when the industry largely abandoned neural approaches as a dead end.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fix, when it arrived, was simple in concept. Stack multiple perceptrons into layers. A hidden layer between input and output can learn intermediate representations that are linearly separable even when the raw inputs are not. Two perceptrons can each draw a line. A third can combine those lines into a non-linear decision boundary. This is the multi-layer perceptron (MLP), and it is the architectural template for every deep network that followed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why this matters for red teaming<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding the perceptron is not an academic exercise for this series. Three properties of single perceptrons translate directly into attack surfaces at scale:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Weights encode priorities.<\/strong>&nbsp;In a trained model, weights reflect what the training data rewarded. If the training data contained biases, those biases are baked into the weights. Adversarial attacks exploit this: craft inputs that manipulate the weighted sum just enough to flip the decision across the boundary. The attacker does not need to understand the full model. They need to understand how small input perturbations shift the sum.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The decision boundary is a geometric surface.<\/strong>&nbsp;Every classifier, no matter how complex, partitions its input space with decision boundaries. Adversarial examples work by finding inputs that sit near those boundaries and nudging them across. A perceptron makes this geometry visible. A deep network hides it behind layers of abstraction, but the principle is identical.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Activation functions gate information flow.<\/strong>\u00a0The choice of activation function determines what signals pass through a neuron and what gets suppressed. In modern networks, ReLU, sigmoid, and softmax each create different failure modes. Understanding the step function in a perceptron gives you the mental model for reasoning about how activation choices affect model behaviour under adversarial conditions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How the perceptron works, where it breaks, and why its limitations define the attack surfaces of every neural network. Part of the AI red teaming series.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[668,630,109,131,51,690,692,136,137,691],"class_list":["post-429","post","type-post","status-publish","format-standard","hentry","category-technology","tag-adversarial-machine-learning","tag-ai-red-teaming","tag-ai-security","tag-artificial-intelligence","tag-cybersecurity","tag-deep-learning-fundamentals","tag-linear-separability","tag-machine-learning","tag-neural-networks","tag-perceptron"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":1,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":430,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts\/429\/revisions\/430"}],"wp:attachment":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}