Body: <p>I'm trying to understand how the logic gates (e.g. AND, OR, NOT, NAND) can be built into single-layer perceptrons.</p>
  <p>I understand specific examples of weights and thresholds for the gates, but I'm stuck on understanding how to translate these to general inequalities for these gates.</p>
  <p>Is my reasoning correct in the table below, or are there cases where these general inequalities do not make sense for this problem? Am I missing other logic gates that can be done in a similar fashion? (e.g., I know XOR cannot)?</p>
  <p>In the table below, a perceptron has two input nodes, and one output node. W1 and W2 are the weights (real values) on those input nodes. T is the threshold, above which, the perceptron will fire. I have come up with example values that would work for each logic gate (e.g., for the AND gate, a perceptron with two input weights, W1 = 1 and W2 = 1, and a threshold = 2, will fire, and I'm trying to understand more generally, what is the equation needed for each gate).</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Gate</th>
  <th style="text-align: left;">Example W1, W2</th>
  <th style="text-align: left;">Threshold</th>
  <th style="text-align: left;">General inequalities</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">AND</td>
  <td style="text-align: left;">1,1</td>
  <td style="text-align: left;">2</td>
  <td style="text-align: left;">W1 + W2 &gt;= t, where W1, W2 &gt; 0</td>
  </tr>
  <tr>
  <td style="text-align: left;">OR</td>
  <td style="text-align: left;">1,1</td>
  <td style="text-align: left;">1</td>
  <td style="text-align: left;">W1 &gt; t or W2 &gt; t</td>
  </tr>
  <tr>
  <td style="text-align: left;">NOT</td>
  <td style="text-align: left;">-1</td>
  <td style="text-align: left;">-0.49</td>
  <td style="text-align: left;">W1 &gt; 2(t)</td>
  </tr>
  <tr>
  <td style="text-align: left;">NAND</td>
  <td style="text-align: left;">-2,-2</td>
  <td style="text-align: left;">3</td>
  <td style="text-align: left;">W1 + W2 &lt;= t</td>
  </tr>
  </tbody>
  </table>
  </div>
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-02T22:42:15.943Z
Comments.Text: This post is not fully clear to me. $W_1$ and $W_2$ are the weights, right? If that's the case, are you assuming binary, integers, or real weights? I suppose that $t$ is the threshold here. The numbers in the second column would be the values of those weights, I suppose. It may be useful to provide more context regarding where you've been studying about perceptrons and how they can learn these logical operations, so that to understand why you're trying to understand what you're trying to understand.
Comments.UserDisplayName: nbro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-03T10:43:25.590Z
Comments.Text: thanks for this. I added more information to the question, I can't add the exact notes I was reading from because of copyright, but the idea is that there is a note that says 'we can use perceptrons to model different logic gates, such as an AND gate. An example of an AND gate set of weights and threshold that would fire for a perceptron is W=1, W2=1 and threshold=2'. But I want to understand further than that, what is the equations that would tell you to let you quickly assess, in any situation, whether the perceptron will fire for the different weights described above.
Comments.UserDisplayName: Slowat_Kela
Tags: <machine-learning><perceptron>
Title: What are the general inequalities needed for the logic gate perceptrons?
UserDisplayName: Slowat_Kela
ThreadText: # What are the general inequalities needed for the logic gate perceptrons?
  
  (Asked by: username_0 on 2021-01-02)
  
  I'm trying to understand how the logic gates (e.g. AND, OR, NOT, NAND) can be built into single-layer perceptrons.
  
  I understand specific examples of weights and thresholds for the gates, but I'm stuck on understanding how to translate these to general inequalities for these gates.
  
  Is my reasoning correct in the table below, or are there cases where these general inequalities do not make sense for this problem? Am I missing other logic gates that can be done in a similar fashion? (e.g., I know XOR cannot)?
  
  In the table below, a perceptron has two input nodes, and one output node. W1 and W2 are the weights (real values) on those input nodes. T is the threshold, above which, the perceptron will fire. I have come up with example values that would work for each logic gate (e.g., for the AND gate, a perceptron with two input weights, W1 = 1 and W2 = 1, and a threshold = 2, will fire, and I'm trying to understand more generally, what is the equation needed for each gate).
  
  | Gate | Example W1, W2 | Threshold | General inequalities |
  | --- | --- | --- | --- |
  | AND | 1,1 | 2 | W1 + W2 >= t, where W1, W2 > 0 |
  | OR | 1,1 | 1 | W1 > t or W2 > t |
  | NOT | -1 | -0.49 | W1 > 2(t) |
  | NAND | -2,-2 | 3 | W1 + W2 <= t |
  
  **Tags:** machine-learning, perceptron
  > **Comments:**
  > **username_1**: This post is not fully clear to me. $W_1$ and $W_2$ are the weights, right? If that's the case, are you assuming binary, integers, or real weights? I suppose that $t$ is the threshold here. The numbers in the second column would be the values of those weights, I suppose. It may be useful to provide more context regarding where you've been studying about perceptrons and how they can learn these logical operations, so that to understand why you're trying to understand what you're trying to understand.  
  > **username_0**: thanks for this. I added more information to the question, I can't add the exact notes I was reading from because of copyright, but the idea is that there is a note that says 'we can use perceptrons to model different logic gates, such as an AND gate. An example of an AND gate set of weights and threshold that would fire for a perceptron is W=1, W2=1 and threshold=2'. But I want to understand further than that, what is the equations that would tell you to let you quickly assess, in any situation, whether the perceptron will fire for the different weights described above.  
  
  ---
  
  ## 0 answers
  
  