Free course · Lesson 1 of 5
Introduction to Artificial Neural Networks (ANNs)
In this lesson you will
- Calculate a neuron's output
- Explain how networks learn from their errors
An Artificial Neural Network (ANN) is inspired by the human brain. It consists of layers of artificial neurons — an input layer, one or more hidden layers, and an output layer. Each connection between neurons has a weight and each neuron has a bias. As data flows through the network, an activation function (like ReLU or Sigmoid) decides whether a neuron should "fire," allowing the network to learn complex patterns.
- Input layer: receives raw data (e.g., pixel values, sensor readings).
- Hidden layers: extract increasingly abstract features — edges, shapes, objects.
- Weights & biases: adjusted during training to minimize error (this is "learning").
- Built and trained using PyTorch or TensorFlow/Keras in Google Colab or Jupyter Notebooks.
💡 Practical Skill: Use Google Colab (free GPU!) to build your first ANN. No local setup needed — just a browser. Start with a simple classifier like predicting pass/fail from study hours.
# A minimal Artificial Neural Network using TensorFlow/Keras# Run in Google Colab or install: pip install tensorflow import tensorflow as tfimport numpy as np # Simple dataset: predict score (0-100) from hours studiedhours = np.array([1, 2, 3, 4, 5, 6, 7, 8], dtype=float)scores = np.array([10, 25, 35, 48, 55, 68, 77, 90], dtype=float) # Build a sequential ANN with 1 hidden layermodel = tf.keras.Sequential([ # Input layer (1 neuron for 1 feature) + Hidden layer (8 neurons, ReLU) tf.keras.layers.Dense(8, activation='relu', input_shape=(1,)), # Output layer (1 neuron for the score prediction) tf.keras.layers.Dense(1)]) # Compile: choose optimizer and loss functionmodel.compile(optimizer='adam', loss='mse') # Train the network (epochs = passes over the data)print("Training neural network...")model.fit(hours, scores, epochs=300, verbose=0)print("Training complete!") # Predict: what score for 4.5 hours of study?prediction = model.predict(np.array([4.5]), verbose=0)print(f"Predicted score for 4.5 hours: {prediction[0][0]:.1f}%")# Expected: around 55-65% (the network learned the pattern!)
Practice exercise
For a neuron with inputs 1, 2 and 4, weights 0.5, 0.25 and −0.5 and bias 0.5, calculate the weighted sum and the ReLU output.
Key takeaways
- A neuron is a weighted sum plus a bias, passed through an activation
- Training adjusts weights to reduce the loss
- The learning rate controls the size of each adjustment
Free self-study lesson — no certificate. For the full instructor-led program, see registration options.