Answers.Body: <p>There are two aspects that you need to consider:</p>
  
  <ol>
  <li><p>Because it is part of the <a href="https://en.wikipedia.org/wiki/Perceptron#Definition" rel="nofollow noreferrer">definition of a perceptron</a>. There are many different mechanisms to implement an OR gate, most of them rather easy. But if you want to implement it based on a perceptron, you have to follow the definition of the perceptron. Otherwise you would just implement an OR gate without using an actual perceptron.</p></li>
  <li><p>The purpose of an neural network is to initialize it more or less randomly without knowing the correct weights and biases for each neuron (or perceptron in your case). You just know the desired behavior of the network and you train it accordingly. In your example you know the desired output of the OR gate and can train your network to give you this desired output. What's bothering you is the fact that you can easily derive the correct weights without actual training the network just by analyzing it. That's because this is a theoretical example to show that a perceptron is capable to learn the behavior of an OR gate. In a real application you would not benefit from artificially crafting an OR gate based on an perceptron.</p></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-20T21:29:03.757Z
Answers.LastActivityDate: 2017-10-20T21:29:03.757Z
Answers.UserDisplayName: Demento
Answers.Body: <blockquote>
    <p>This would successfully simulate an OR gate.</p>
  </blockquote>
  
  <p>Of course. In fact, hardware implementation of an OR gate needs <a href="https://en.wikipedia.org/wiki/OR_gate#Implementations" rel="nofollow noreferrer">just a few transistors</a>. It may sound surprising, but the best python implementation of OR is <code>a or b</code>.</p>
  
  <blockquote>
    <p>So why do I need to "train" any weights?</p>
  </blockquote>
  
  <p>It's one of the simplest functions out there, everyone understands how OR works just from the boolean table. The task shows that a neural network can <em>learn</em> it as well, just from examples and without specification what a logical operation is and how to wire it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-20T21:00:51.073Z
Answers.LastActivityDate: 2017-10-20T21:00:51.073Z
Answers.UserDisplayName: Maxim
Body: <p>Without using any of Matlab's neural network tools, I'm writing a program to simulate an OR gate with a perceptron. I have seen many tutorials, but I still can't understand why we need weights to train a perceptron for such a simple purpose.  </p>
  
  <p>One way is to program the perceptron with the conditions <code>(0,0)=0. (1,0)=1. (0,1)=1. (1,1)=1</code>. So the two inputs to the perceptron would be either zeroes or ones. I don't see the purpose of weights here. Assuming weights are 1, for the second training example, the output would be <code>1*1 + 0*1 = 1</code>. For the last example, it would be <code>1*1 + 1*1 = 2</code>. So an activation function which says <code>if output &gt;= 1, output = 1 else output =0; end</code> should suffice. This would successfully simulate an OR gate. So why do I need to "train" any weights?    </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T07:20:40.327Z
Comments.Text: Update: I got a hint from the Perceptron Learning example. University of Kurdistan. The table on page 4 is self explanatory, but the question still persists. Why weights? http://eng.uok.ac.ir/esmaili/teaching/spring2012/nn/slides/Perceptron%20Learning%20Example.pdf
Comments.UserDisplayName: Nav
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T13:55:18.400Z
Comments.Text: Why would you use a perceptron as an OR gate at all?  It is a pedagogical tool to show how a perceptron can map to a specific function.
Comments.UserDisplayName: antlersoft
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-21T02:12:35.020Z
Comments.Text: @antlersoft: It's for a pedagogical purpose. I'm learning how these things work. Hard to believe these techniques model the brain. Looks like it's designed to model the computer more than a brain. Even if the brain performs logical operations.
Comments.UserDisplayName: Nav
Tags: <neural-networks><artificial-neuron>
Title: Why do we need weights when training a perceptron as an OR gate?
UserDisplayName: Nav
ThreadText: # Why do we need weights when training a perceptron as an OR gate?
  
  (Asked by: username_0 on 2017-10-19)
  
  Without using any of Matlab's neural network tools, I'm writing a program to simulate an OR gate with a perceptron. I have seen many tutorials, but I still can't understand why we need weights to train a perceptron for such a simple purpose.
  
  One way is to program the perceptron with the conditions `(0,0)=0. (1,0)=1. (0,1)=1. (1,1)=1`. So the two inputs to the perceptron would be either zeroes or ones. I don't see the purpose of weights here. Assuming weights are 1, for the second training example, the output would be `1*1 + 0*1 = 1`. For the last example, it would be `1*1 + 1*1 = 2`. So an activation function which says `if output >= 1, output = 1 else output =0; end` should suffice. This would successfully simulate an OR gate. So why do I need to "train" any weights?
  
  **Tags:** neural-networks, artificial-neuron
  
  > **Comments:**
  > **username_0**: Update: I got a hint from the Perceptron Learning example. University of Kurdistan. The table on page 4 is self explanatory, but the question still persists. Why weights? http://eng.uok.ac.ir/esmaili/teaching/spring2012/nn/slides/Perceptron%20Learning%20Example.pdf  
  > **username_1**: Why would you use a perceptron as an OR gate at all?  It is a pedagogical tool to show how a perceptron can map to a specific function.  
  > **username_0**: @username_1: It's for a pedagogical purpose. I'm learning how these things work. Hard to believe these techniques model the brain. Looks like it's designed to model the computer more than a brain. Even if the brain performs logical operations.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-10-20. Score: 1 | Accepted answer
  
  There are two aspects that you need to consider:
  
  1. Because it is part of the [definition of a perceptron](https://en.wikipedia.org/wiki/Perceptron#Definition). There are many different mechanisms to implement an OR gate, most of them rather easy. But if you want to implement it based on a perceptron, you have to follow the definition of the perceptron. Otherwise you would just implement an OR gate without using an actual perceptron.
  2. The purpose of an neural network is to initialize it more or less randomly without knowing the correct weights and biases for each neuron (or perceptron in your case). You just know the desired behavior of the network and you train it accordingly. In your example you know the desired output of the OR gate and can train your network to give you this desired output. What's bothering you is the fact that you can easily derive the correct weights without actual training the network just by analyzing it. That's because this is a theoretical example to show that a perceptron is capable to learn the behavior of an OR gate. In a real application you would not benefit from artificially crafting an OR gate based on an perceptron.
  
  
  ---
  
  ### Answer by username_3 on 2017-10-20. Score: 1
  
  > This would successfully simulate an OR gate.
  
  Of course. In fact, hardware implementation of an OR gate needs [just a few transistors](https://en.wikipedia.org/wiki/OR_gate#Implementations). It may sound surprising, but the best python implementation of OR is `a or b`.
  
  > So why do I need to "train" any weights?
  
  It's one of the simplest functions out there, everyone understands how OR works just from the boolean table. The task shows that a neural network can *learn* it as well, just from examples and without specification what a logical operation is and how to wire it.
  
  
  ---
  
  