鑑別器
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
GAN 中的鑑別器只是分類器。它會嘗試將實際資料與產生器建立的資料區分開來。它可以使用任何網路架構,以便根據所分類的資料類型進行分類。

圖 1:鑑別器訓練中的反向傳播。
鑑別器訓練資料
判別器的訓練資料來自兩個來源:
- 實際資料示例,例如真實人物的相片。在訓練期間,判別器會將這些例項用作正面示例。
- 產生器建立的假資料例項。鑑別器會在訓練期間使用這些例項做為負面示例。
在圖 1 中,兩個「Sample」方塊代表這兩個資料來源,會饋送至判別器。在鑑別器訓練期間,產生器不會進行訓練。其權重會保持不變,同時產生範例供判別器訓練。
訓練鑑別器
判別器會連結至兩個 loss 函式。在鑑別器訓練期間,鑑別器會忽略產生器損失,只使用鑑別器損失。我們會在產生器訓練期間使用產生器損失,詳情請參閱下一節。
在鑑別器訓練期間:
- 鑑別器會將產生器產生的真實資料和假資料分類。
- 辨別器損失會對辨別器處以罰分,因為辨別器將真實例項誤分為假,或將假例項誤分為真。
- 鑑別器會透過鑑別器網路,從鑑別器損失中反向傳播更新權重。
在下一節中,我們將說明為何產生器損失會連結至判別器。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-02-26 (世界標準時間)。
[null,null,["上次更新時間:2025-02-26 (世界標準時間)。"],[[["\u003cp\u003eThe discriminator in a GAN is a classifier that distinguishes real data from fake data generated by the generator.\u003c/p\u003e\n"],["\u003cp\u003eDiscriminator training involves using real and fake data to update its weights through backpropagation and minimize the discriminator loss.\u003c/p\u003e\n"],["\u003cp\u003eDuring discriminator training, the generator's weights remain constant, and the generator loss is ignored.\u003c/p\u003e\n"]]],[],null,["# The Discriminator\n\n\u003cbr /\u003e\n\nThe discriminator in a GAN is simply a classifier. It tries to distinguish real\ndata from the data created by the generator. It could use any network\narchitecture appropriate to the type of data it's classifying.\n\n**Figure 1: Backpropagation in discriminator training.**\n\nDiscriminator Training Data\n---------------------------\n\nThe discriminator's training data comes from\ntwo sources:\n\n- **Real data** instances, such as real pictures of people. The discriminator uses these instances as positive examples during training.\n- **Fake data** instances created by the generator. The discriminator uses these instances as negative examples during training.\n\nIn Figure 1, the two \"Sample\" boxes represent these two data sources feeding\ninto the discriminator. During discriminator training the generator does not\ntrain. Its weights remain constant while it produces examples for the\ndiscriminator to train on.\n\nTraining the Discriminator\n--------------------------\n\nThe discriminator connects to two [loss](/machine-learning/glossary#loss)\nfunctions. During discriminator training, the discriminator ignores the\ngenerator loss and just uses the discriminator loss. We use the generator loss\nduring generator training, as described in [the next section](/machine-learning/gan/generator).\n\nDuring discriminator training:\n\n1. The discriminator classifies both real data and fake data from the generator.\n2. The discriminator loss penalizes the discriminator for misclassifying a real instance as fake or a fake instance as real.\n3. The discriminator updates its weights through [backpropagation](https://developers.google.com/machine-learning/glossary/#b) from the discriminator loss through the discriminator network.\n\nIn the next section we'll see why the generator loss connects to the\ndiscriminator."]]