開始使用免費開始

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())
編輯並執行程式碼