1. Home
  2. Explore
  3. Computer Science
  4. Artificial Neural Networks

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Artificial Neural Networks

Speaker 1Speaker 2

Artificial Neural Networks

9:58
0:00-9:58
  1. Hope

    Today we are building a foundation for understanding artificial neural networks, step by step, without treating the mathematics as something frightening. Neural networks are behind systems such as ChatGPT, Gemini, Tesla's self-driving cars, and bank fraud-detection systems. The goal is to understand what happens inside one when it receives data and produces a decision.

  2. Corey

    A useful place to begin is with the nervous system in the human body, because artificial neural networks are based on that general idea. Imagine a car moving toward you very quickly. Your eyes see it, your ears may hear it, and those signals travel to neurons. The neurons process the information, some become activated, and the result is a decision to jump out of the way.

  3. Hope

    And compare that with sitting on a sofa listening to relaxing music. Your ears still receive an input signal, but processing produces a different pattern of activated neurons, leading to a feeling of relaxation. So different inputs activate different neurons, and the pattern of activation influences the decision or response.

  4. Corey

    Artificial neural networks apply a similar basic concept. They receive inputs, perform processing, activate certain neurons, and produce an output. The central question is: how does the network calculate which neurons should be activated?

  5. Hope

    At a high level, a neural network has an input layer, one or more hidden layers, and an output layer. The input layer receives the data. It does not perform the main calculations; it passes the data onward to the hidden layer.

  6. Corey

    The hidden layer is where the processing happens. A network can contain many hidden layers, and each hidden layer can contain many neurons. For a simple example, we can imagine four neurons in the input layer, one hidden layer with two neurons, and then an output layer.

  7. Hope

    The output layer receives information from the previous layer, processes it, and produces the network's decision. When information moves from the input layer through the hidden layer and finally to the output layer, that process is called forward propagation.

  8. Corey

    Let's make that concrete with a fitness example. Suppose our data records how many hours a person exercises each week, how many times they eat junk food each week, how many hours they sleep per day, and how many liters of water they drink. Those four measurements are the features, or inputs.

  9. Hope

    The label is whether the person is fit. We can represent fit with a one and unfit with a zero. Because there are only two possible outcomes, this is a binary classification problem.

  10. Corey

    During training, the network receives many examples that include both the four features and the correct label. Later, we want to give it the four features for a new person without the label, and have it predict whether that person is fit.

  11. Hope

    For one example, each feature is placed into an input neuron. You might have values such as six hours of exercise per week, eight instances of another measurement, 2.5 hours or units for another feature, and a value for water consumption. The important point is that the network receives numerical values.

  12. Corey

    At the beginning, the network does not understand what any of those numbers mean. It does not automatically know that exercise may support fitness or that junk food may work against it. It begins with randomly assigned weights and must learn how the features influence the label.

  13. Hope

    A weight is assigned to each connection between neurons. A larger weight gives an input more influence on the next neuron's calculation, while a smaller weight gives it less influence. If a weight is negative, that input can influence the result in the opposite direction.

  14. Corey

    So the first hidden neuron combines the inputs and their weights. It multiplies each input by its corresponding weight, adds all those products together, and then adds a value called the bias. In compact form, the calculation is often written as the sum of x times w plus b.

  15. Hope

    The bias gives the neuron an additional adjustable value. In the example, a randomly chosen bias helps produce a first calculated value of 11.15 for one hidden neuron. The exact number is not the main lesson; the important idea is that inputs, weights, and bias are combined before activation is considered.

  16. Corey

    That calculated value is then passed through an activation function. The activation function helps determine whether the neuron should be considered active and what value it should send forward. Without activation functions, the network would have much less ability to represent different patterns.

  17. Hope

    For the hidden layer in this example, the activation function is ReLU. ReLU means the maximum of zero and the input value. A positive value stays as it is, while a negative value becomes zero.

  18. Corey

    That means a positive result such as 11.15 remains 11.15, so the neuron is active. If the calculation had produced a negative number, ReLU would output zero, meaning that neuron would not be activated for that input.

  19. Hope

    The second hidden neuron performs the same general process, but it has different weights and can therefore produce a different value. In the example, its calculation produces 7.95. Both hidden-neuron outputs are then passed to the output layer.

  20. Corey

    The output neuron also has weights for the incoming values and its own bias. It combines the two hidden-layer outputs using the same weighted-sum idea. With the example's values, the output calculation produces a value of 14.146 before the output activation function is applied.

  21. Hope

    Because this is binary classification, the output layer uses a sigmoid activation function rather than ReLU. Sigmoid converts the calculated value into a number between zero and one. Its formula is one divided by one plus e to the negative z, where z is the value calculated before activation.

  22. Corey

    The resulting number can be interpreted as the network's prediction or confidence for the positive class. A value between zero and 0.5 is treated as not activated, while a value between 0.5 and one is treated as activated. So a result of 0.99 indicates a very confident prediction for the positive class.

  23. Hope

    At this point, the information has traveled all the way from the input layer to the output layer, so forward propagation is complete. But the network has only made a prediction. To learn, it must compare that prediction with the known correct label.

  24. Corey

    This is where the loss function comes in. For binary classification, one suitable choice is binary cross-entropy. It measures how far the predicted output is from the actual output. A loss close to zero means the prediction is correct or very close, while a large loss means the prediction is far from the correct answer.

  25. Hope

    The example illustrates why confidence matters. If the actual label is zero but the network predicts 0.99, that is a confidently wrong prediction, so the binary cross-entropy loss is high—about 4.6 in the example. A prediction of 0.5 produces a loss of about 0.69 in that illustration, while a prediction of 0.1, which is closer to the actual zero, produces a much smaller loss of about 0.1.

  26. Corey

    Once the loss is known, the network uses backpropagation. Backpropagation moves backward through the network one layer at a time and calculates how much each weight contributed to the error. The network can then adjust those weights so that future predictions are more accurate.

  27. Hope

    Gradient descent is the method used to update the weights. The general idea is to move the weights in a direction that reduces the loss. A simplified update has the form: new weight equals old weight minus the learning rate multiplied by a derivative.

  28. Corey

    The derivative tells us how strongly a particular weight contributes to the loss and in which direction it should change. For example, if a weight connected to junk-food frequency is positive but the data suggests that junk food should negatively influence fitness, the training process may push that weight downward and potentially make it negative.

  29. Hope

    The learning rate controls the size of each adjustment. With a small learning rate, the loss decreases gradually, step by step. With a learning rate that is too large, the updates can overshoot the best point and cause the loss to oscillate instead of steadily approaching zero.

  30. Corey

    Training repeats the full cycle. First, the network performs forward propagation and generates an output. Next, it calculates the loss by comparing that output with the actual label. Then backpropagation and gradient descent adjust the weights, and the process is repeated for more examples.

  31. Hope

    After hundreds, thousands, or even millions of examples, the weights can gradually be updated into a useful pattern. The result is a generalized model that can receive new data without a label and make a prediction with good accuracy, although not with a guarantee of one hundred percent accuracy.

  32. Corey

    The mathematics is important for understanding what is happening, but machine-learning libraries automate most of the calculations. With tools such as TensorFlow and Keras, or alternatives such as PyTorch, a few lines can specify the network layers and their activation functions.

  33. Hope

    For this example, the hidden layer can be configured with ReLU and the output layer with sigmoid. Other lines can specify binary cross-entropy as the loss function and gradient descent as the optimizer. The program then performs the weighted sums, activations, loss calculation, backpropagation, and weight updates automatically.

  34. Corey

    So the practical skill is not manually calculating every value forever. It is understanding which activation function, loss function, and optimizer fit the problem, preparing the data correctly, and passing the right information to the program. The software handles the repetitive calculations, while the human still needs to understand and configure the learning process.

  35. Hope

    One final point is that neural networks work with numerical inputs. Even when the original information is not obviously numerical, it must be represented as numbers before the network can process it. That is why image classification requires converting image information into numerical input.

  36. Corey

    The next example described is handwritten-digit recognition. Unlike the fitness example, which has two classes—fit and unfit—digit recognition has multiple classes, from zero through nine. That makes it a multi-class classification problem, but the same broad ideas still apply: numerical inputs, forward propagation, an output prediction, loss calculation, and learning through backpropagation.

  37. Hope

    And that gives us the complete foundation: neural networks imitate the general idea of inputs being processed by connected units, organize that processing into layers, use weights and biases to calculate values, use activation functions to determine outputs, and learn by reducing loss through backpropagation and gradient descent.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent