What is an activation function in a neural network?
An activation function decides if a neuron should be activated or not. It adds non-linearity to the network, helping it learn complex patterns.
Click to reveal answer
beginner
Why do we need non-linear activation functions?
Non-linear activation functions let neural networks learn and model complex data. Without them, the network would behave like a simple linear model.
Click to reveal answer
beginner
Name three common activation functions used in neural networks.
Three common activation functions are: Sigmoid, ReLU (Rectified Linear Unit), and Tanh (Hyperbolic Tangent).
Click to reveal answer
beginner
What is the output range of the Sigmoid activation function?
The Sigmoid function outputs values between 0 and 1, making it useful for probabilities.
Click to reveal answer
beginner
How does the ReLU activation function work?
ReLU outputs the input directly if it is positive; otherwise, it outputs zero. This helps the network learn faster and reduces the chance of vanishing gradients.
Click to reveal answer
What does an activation function add to a neural network?
AMore layers
BNon-linearity
CData normalization
DWeight initialization
✗ Incorrect
Activation functions add non-linearity, allowing the network to learn complex patterns.
Which activation function outputs values between -1 and 1?
AReLU
BSigmoid
CTanh
DSoftmax
✗ Incorrect
Tanh outputs values between -1 and 1, centering data around zero.
What is a key advantage of ReLU over Sigmoid?
AReLU outputs probabilities
BReLU is non-differentiable
CReLU outputs values between 0 and 1
DReLU helps reduce vanishing gradients
✗ Incorrect
ReLU helps reduce the vanishing gradient problem, allowing faster training.
Which activation function is best for the output layer in binary classification?
ASigmoid
BTanh
CReLU
DLinear
✗ Incorrect
Sigmoid outputs values between 0 and 1, suitable for binary classification probabilities.
What happens to negative inputs in the ReLU function?
AThey become zero
BThey are passed through unchanged
CThey become one
DThey become negative one
✗ Incorrect
ReLU outputs zero for any negative input.
Explain what an activation function is and why it is important in neural networks.
Think about how neurons decide to 'fire' or not.
You got /3 concepts.
Describe the differences between Sigmoid, Tanh, and ReLU activation functions.
Consider their output values and where they are commonly used.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of an activation function in a neural network?
easy
A. To split data into training and testing sets
B. To initialize the weights of the network
C. To reduce the size of the dataset
D. To add non-linearity so the network can learn complex patterns
Solution
Step 1: Understand the role of activation functions
Activation functions introduce non-linearity to the network, allowing it to learn complex patterns beyond simple straight lines.
Step 2: Compare with other options
Weight initialization, data splitting, and dataset size reduction are unrelated to activation functions.
Final Answer:
To add non-linearity so the network can learn complex patterns -> Option D
Quick Check:
Activation function purpose = Add non-linearity [OK]
Hint: Activation functions make models learn complex patterns [OK]
Common Mistakes:
Confusing activation functions with weight initialization
Thinking activation functions reduce dataset size
Believing activation functions split data
2. Which of the following is the correct Python syntax to apply the ReLU activation function on a variable x using NumPy?
easy
A. relu_x = np.maximum(0, x)
B. relu_x = np.min(0, x)
C. relu_x = np.exp(x)
D. relu_x = np.log(x)
Solution
Step 1: Recall ReLU function definition
ReLU returns the maximum between 0 and the input value, so np.maximum(0, x) is correct.
Step 2: Check other options
np.min(0, x) returns the minimum, which is incorrect. np.exp(x) and np.log(x) are exponential and logarithm functions, not ReLU.
Final Answer:
relu_x = np.maximum(0, x) -> Option A
Quick Check:
ReLU = max(0, x) [OK]
Hint: ReLU = max between zero and input [OK]
Common Mistakes:
Using np.min instead of np.maximum
Confusing ReLU with exponential or log functions
Forgetting to import numpy as np
3. Given the following Python code using NumPy, what is the output of print(output)?
import numpy as np
x = np.array([-2, 0, 3])
output = 1 / (1 + np.exp(-x))
print(output)
medium
A. [0 0 3]
B. [0.11920292 0.5 0.95257413]
C. [-2 0 3]
D. [1 1 1]
Solution
Step 1: Identify the activation function used
The code applies the sigmoid function: 1 / (1 + exp(-x)) on each element of x.
Step 2: Calculate sigmoid values for each element
For x = -2: sigmoid ≈ 0.1192; for 0: sigmoid = 0.5; for 3: sigmoid ≈ 0.9526.
Final Answer:
[0.11920292 0.5 0.95257413] -> Option B
Quick Check:
Sigmoid([-2,0,3]) = [0.119,0.5,0.953] [OK]
Hint: Sigmoid outputs values between 0 and 1 [OK]
Common Mistakes:
Confusing sigmoid with identity function
Expecting original input as output
Miscomputing exponential values
4. The following code attempts to implement the Tanh activation function but has an error. What is the error?
A. The denominator should be (np.exp(x) + np.exp(-x)) instead of (np.exp(x) + np.exp(x))
B. The numerator should be (np.exp(x) + np.exp(-x))
C. The function should use np.tanh(x) directly
D. The function is missing a return statement
Solution
Step 1: Review the Tanh formula
Tanh(x) = (exp(x) - exp(-x)) / (exp(x) + exp(-x)). The denominator in the code is incorrect.
Step 2: Identify the error in denominator
The code uses (np.exp(x) + np.exp(x)) which doubles exp(x) instead of adding exp(-x).
Final Answer:
The denominator should be (np.exp(x) + np.exp(-x)) instead of (np.exp(x) + np.exp(x)) -> Option A
Quick Check:
Tanh denominator = exp(x)+exp(-x) [OK]
Hint: Check denominator carefully for plus and minus signs [OK]
Common Mistakes:
Copying exp(x) twice in denominator
Swapping numerator and denominator terms
Forgetting to return the value
5. You want to design a neural network for a binary classification task. Which activation function should you use in the output layer to get a probability between 0 and 1, and why?
hard
A. Tanh, because it outputs values between -1 and 1
B. ReLU, because it outputs only positive values
C. Sigmoid, because it outputs values between 0 and 1 suitable for probabilities
D. Linear, because it outputs raw scores
Solution
Step 1: Understand output layer needs for binary classification
The output should represent a probability, so it must be between 0 and 1.
Step 2: Match activation functions to output range
Sigmoid outputs between 0 and 1, perfect for probabilities. ReLU outputs 0 or more but unbounded. Tanh outputs between -1 and 1, not suitable for probabilities. Linear outputs any real number.
Final Answer:
Sigmoid, because it outputs values between 0 and 1 suitable for probabilities -> Option C
Quick Check:
Binary output needs sigmoid for probability [OK]
Hint: Use sigmoid for binary output probabilities [OK]
Common Mistakes:
Using ReLU or Tanh in output layer for probabilities
Choosing linear activation for classification output
Not considering output range needed
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.