Project 12: Mean Squared Error Calculator
ML Engineer
Builds on these lessons
Current Task
Objective
A loss function measures how wrong a prediction is — MeanSquaredError is one of many built-in Keras loss classes you can call directly.
Task: compute the mean squared error between true and predicted values and print it.
index.py
import tensorflow as tf
y_true = [1.0, 0.0]
y_pred = [0.9, 0.2]
mse = tf.keras.losses.MeanSquaredError()
print(mse(y_true, y_pred).numpy())
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview