WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

TensorFlow · Basic · question 12 of 100

What is an activation function, and what are some common examples used in TensorFlow?

📕 Buy this interview preparation book: 100 TensorFlow questions & answers — PDF + EPUB for $5

An activation function is a mathematical function applied to the output of a neuron in a neural network. The purpose of an activation function is to introduce non-linearity into the output of the neuron, which allows the neural network to learn more complex and abstract relationships between inputs and outputs.

Here are some common activation functions used in TensorFlow:

ReLU (Rectified Linear Unit): The ReLU activation function is a piecewise linear function that returns the input value if it is positive, and 0 otherwise. The ReLU function is widely used in deep learning because it is simple, efficient, and can help to prevent the vanishing gradient problem. The ReLU function can be defined in TensorFlow as follows:

    tf.keras.layers.ReLU()

Sigmoid: The sigmoid activation function is a smooth, S-shaped function that returns a value between 0 and 1. The sigmoid function is often used in binary classification problems because it can be interpreted as the probability of a positive class. The sigmoid function can be defined in TensorFlow as follows: scss Copy code tf.keras.activations.sigmoid()

Tanh (Hyperbolic Tangent): The tanh activation function is a smooth, S-shaped function that returns a value between -1 and 1. The tanh function is often used in recurrent neural networks because it can help to prevent the exploding gradient problem. The tanh function can be defined in TensorFlow as follows:

    tf.keras.activations.tanh()

Softmax: The softmax activation function is used in the output layer of a neural network to produce a probability distribution over multiple classes. The softmax function normalizes the outputs of the previous layer so that they sum to 1, and then applies the exponential function to each output. The softmax function can be defined in TensorFlow as follows:

    tf.keras.activations.softmax()

There are many other activation functions that can be used in TensorFlow, including the Leaky ReLU, ELU, and Swish functions. The choice of activation function depends on the specific problem being solved and the architecture of the neural network.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic TensorFlow interview — then scores it.
📞 Practice TensorFlow — free 15 min
📕 Buy this interview preparation book: 100 TensorFlow questions & answers — PDF + EPUB for $5

All 100 TensorFlow questions · All topics