开始使用免费开始使用

TensorFlow 中的损失函数

在本练习中,您将使用 King County 房价数据集来计算损失。给定目标值 price(房价张量)和 predictions(预测房价张量)。您将评估损失函数,并打印损失值。

本练习是课程的一部分

Python 中的 TensorFlow 入门

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the keras module from tensorflow
____

# Compute the mean squared error (mse)
loss = keras.losses.____(price, predictions)

# Print the mean squared error (mse)
print(loss.numpy())
编辑并运行代码