0
0
TensorFlowml~5 mins

Loss functions (MSE, cross-entropy) in TensorFlow - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of a loss function in machine learning?
A loss function measures how well a model's predictions match the actual data. It tells the model how wrong it is so it can learn and improve.
Click to reveal answer
beginner
Explain Mean Squared Error (MSE) loss function.
MSE calculates the average of the squares of the differences between predicted and actual values. It punishes bigger errors more, helping models learn precise predictions.
Click to reveal answer
beginner
What type of problems is cross-entropy loss used for?
Cross-entropy loss is used for classification problems. It measures how close the predicted probabilities are to the actual class labels.
Click to reveal answer
intermediate
How does cross-entropy loss handle predictions that are very wrong?
Cross-entropy loss gives a high penalty when the predicted probability for the true class is very low, encouraging the model to predict probabilities closer to the true labels.
Click to reveal answer
beginner
Show a simple TensorFlow code snippet to compute MSE loss.
import tensorflow as tf

true = tf.constant([3.0, -0.5, 2.0, 7.0])
pred = tf.constant([2.5, 0.0, 2.0, 8.0])

mse = tf.reduce_mean(tf.square(pred - true))
print(f'MSE Loss: {mse.numpy()}')
Click to reveal answer
Which loss function is best suited for a regression problem?
ACross-entropy
BCategorical accuracy
CHinge loss
DMean Squared Error (MSE)
Cross-entropy loss is mainly used for which type of machine learning task?
AClassification
BRegression
CClustering
DDimensionality reduction
What does a high cross-entropy loss value indicate?
APredictions are very close to true labels
BPredictions are very wrong
CModel is perfectly trained
DLoss function is not working
In TensorFlow, which function can be used to compute MSE loss manually?
Atf.reduce_mean(tf.square(y_true - y_pred))
Btf.nn.softmax_cross_entropy_with_logits
Ctf.argmax
Dtf.reduce_sum(y_true + y_pred)
Which loss function punishes bigger errors more strongly?
ACross-entropy
BMean Absolute Error
CMean Squared Error
DHinge loss
Describe how Mean Squared Error (MSE) and cross-entropy loss differ in their use and calculation.
Think about the type of problem and how errors are measured.
You got /5 concepts.
    Explain why loss functions are important in training machine learning models.
    Consider the role of feedback in learning.
    You got /4 concepts.