TW202247044A - Method for optimizing the generative adversarial network and electronic equipment - Google Patents
Method for optimizing the generative adversarial network and electronic equipment Download PDFInfo
- Publication number
- TW202247044A TW202247044A TW110118136A TW110118136A TW202247044A TW 202247044 A TW202247044 A TW 202247044A TW 110118136 A TW110118136 A TW 110118136A TW 110118136 A TW110118136 A TW 110118136A TW 202247044 A TW202247044 A TW 202247044A
- Authority
- TW
- Taiwan
- Prior art keywords
- weight
- discriminator
- generator
- network optimization
- loss function
- Prior art date
Links
Images
Landscapes
- Mobile Radio Communication Systems (AREA)
Abstract
Description
本申請涉及生成對抗網路技術領域,具體涉及一種生成對抗網路優化方法及電子設備。The present application relates to the technical field of generative confrontation networks, in particular to a method for optimizing generative confrontation networks and electronic equipment.
生成對抗網路(Generative Adversarial Network,GAN)由生成器和判別器構成,藉由生成器和判別器之對抗訓練來使得生成器產生之樣本服從真實資料分佈。訓練過程中,生成器根據輸入之隨機雜訊生成樣本圖像,其目標係儘量生成真實之圖像去欺騙判別器。判別器學習判別樣本圖像之真偽,其目標係儘量分辨出真實樣本圖像與生成器生成之樣本圖像。The Generative Adversarial Network (GAN) is composed of a generator and a discriminator. Through the confrontation training of the generator and the discriminator, the samples generated by the generator obey the real data distribution. During the training process, the generator generates sample images according to the input random noise, and its goal is to generate real images as much as possible to deceive the discriminator. The discriminator learns to distinguish the authenticity of the sample image, and its goal is to distinguish the real sample image from the sample image generated by the generator as much as possible.
然,生成對抗網路之訓練自由度太大,於訓練不穩定時,生成器和判別器很容易陷入不正常之對抗狀態,發生模式崩潰(Mode collapse),導致生成樣本圖像之多樣性不足。However, the degree of freedom in the training of generative confrontation networks is too large. When the training is unstable, the generator and the discriminator can easily fall into an abnormal confrontation state, and mode collapse occurs, resulting in insufficient diversity of generated sample images. .
鑒於此,本申請提供一種生成對抗網路優化方法及電子設備,能夠平衡生成器和判別器之損失,使得生成器和判別器具有相同之學習能力,從而提高生成對抗網路之穩定性。In view of this, the present application provides an optimization method and electronic equipment for generative adversarial networks, which can balance the losses of the generator and the discriminator, so that the generator and the discriminator have the same learning ability, thereby improving the stability of the generative adversarial network.
本申請之生成對抗網路優化方法包括:確定生成器之第一權重與判別器之第二權重,所述第一權重與所述第二權重相等,所述第一權重用以表示所述生成器之學習能力,所述第二權重用以表示所述判別器之學習能力;交替反覆運算訓練所述生成器與所述判別器,直至所述生成器與所述判別器均收斂。The generation confrontation network optimization method of the present application includes: determining the first weight of the generator and the second weight of the discriminator, the first weight is equal to the second weight, and the first weight is used to represent the generated The learning ability of the discriminator, the second weight is used to represent the learning ability of the discriminator; the generator and the discriminator are trained alternately and repeatedly until both the generator and the discriminator converge.
於本申請實施例中,所述學習能力與所述第一權重或所述第二權重呈正相關關係。In the embodiment of the present application, the learning ability is positively correlated with the first weight or the second weight.
本申請之電子設備包括記憶體及處理器,所述記憶體用以存儲電腦程式,所述電腦程式被所述處理器調用時,實現本申請之生成對抗網路優化方法。The electronic device of the present application includes a memory and a processor, the memory is used to store a computer program, and when the computer program is invoked by the processor, the method for generating a confrontational network optimization of the present application is implemented.
本申請藉由梯度下降法反覆運算更新生成器之第一權重與判別器之第二權重,隨著訓練週期之加長動態調整生成器與判別器之學習率,直至所述生成器之損失函數與所述判別器之損失函數均收斂,從而得到最優之權重。所述第一權重與所述第二權重相等,使得所述生成器和所述判別器具有相同之學習能力,從而提高生成對抗網路之穩定性。This application uses the gradient descent method to repeatedly calculate and update the first weight of the generator and the second weight of the discriminator, and dynamically adjust the learning rate of the generator and the discriminator as the training period increases until the loss function of the generator and The loss functions of the discriminators all converge to obtain optimal weights. The first weight is equal to the second weight, so that the generator and the discriminator have the same learning ability, thereby improving the stability of the generated adversarial network.
為了能夠更清楚地理解本申請之上述目的、特徵和優點,下面結合附圖和具體實施例對本申請進行詳細描述。需要說明的是,於不衝突之情況下,本申請之實施例及實施例中之特徵可以相互組合。於下面之描述中闡述了很多具體細節以便於充分理解本申請,所描述之實施例僅係本申請一部分實施例,而不係全部之實施例。In order to understand the above-mentioned purpose, features and advantages of the present application more clearly, the present application will be described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the case of no conflict, the embodiments of the present application and the features in the embodiments can be combined with each other. A lot of specific details are set forth in the following description to facilitate a full understanding of the present application, and the described embodiments are only part of the embodiments of the present application, not all of them.
需要說明的是,雖於流程圖中示出了邏輯順序,但於某些情況下,可以以不同於流程圖中之循序執行所示出或描述之步驟。本申請實施例中公開之方法包括用於實現方法之一個或複數步驟或動作。方法步驟和/或動作可以於不脫離請求項之範圍之情況下彼此互換。換句話說,除非指定步驟或動作之特定順序,否則特定步驟和/或動作之順序和/或使用可以於不脫離請求項範圍之情況下被修改。It should be noted that although a logical sequence is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order than in the flow chart. The methods disclosed in the embodiments of the present application include one or a plurality of steps or actions for realizing the methods. The method steps and/or actions may be interchanged with one another without departing from the scope of the claims. In other words, unless a specific order of steps or actions is specified, the order and/or use of specific steps and/or actions may be modified without departing from the scope of the claims.
生成對抗網路通常用於資料增廣,於樣本資料難以收集時,可藉由少量之樣本資料來訓練生成大規模之樣本資料,從而解決樣本資料不足之問題。但生成對抗網路於訓練過程中容易發生梯度消失、訓練不穩定及收斂速度慢等問題。當訓練不穩定時,生成對抗網路容易發生模式崩潰,導致生成樣本資料之多樣性不足。Generative adversarial networks are usually used for data augmentation. When sample data is difficult to collect, a small amount of sample data can be used to train and generate large-scale sample data, thereby solving the problem of insufficient sample data. However, the GAN is prone to problems such as gradient disappearance, unstable training, and slow convergence during the training process. When the training is unstable, GAN is prone to mode collapse, resulting in insufficient diversity of generated sample data.
基於此,本申請提供一種生成對抗網路優化方法、裝置、電子設備及存儲介質,能夠平衡生成器和判別器之損失,使得生成器和判別器具有相同之學習能力,從而提高生成對抗網路之穩定性。Based on this, the present application provides a method, device, electronic device and storage medium for generating a confrontation network, which can balance the losses of the generator and the discriminator, so that the generator and the discriminator have the same learning ability, thereby improving the performance of the generative confrontation network. of stability.
參照圖1,圖1為生成對抗網路10之示意圖。所述生成對抗網路10包括生成器11與判別器12。生成器11用以接收雜訊樣本z並生成第一圖像,並將生成之第一圖像與從資料樣本x中獲取之第二圖像一起饋送到判別器12中,判別器12接收第一圖像和第二圖像並輸出真假判別之概率D,所述概率D之取值為[0,1],1表示判別結果為真,0表示判別結果為假。Referring to FIG. 1 , FIG. 1 is a schematic diagram of a generative
於本申請實施例中,生成器11與判別器12均為神經網路,所述神經網路包括,但不限於,卷積神經網路(Convolutional Neural Networks,CNN),迴圈神經網路(Recurrent Neural Network,RNN)或深度神經網路(Deep Neural Networks,DNN)等。In the embodiment of the present application, both the
於生成對抗網路10之訓練過程中,生成器11與判別器12係交替反覆運算訓練,且均藉由各自之代價函數(Cost)或損失函數(Loss)優化各自之網路。例如,當訓練生成器11時,固定判別器12之權重,更新生成器11之權重;當訓練判別器12時,固定生成器11之權重,更新判別器12之權重。生成器11與判別器12均極力優化各自之網路,從而形成競爭對抗,直到雙方達到一個動態之平衡,即納什均衡。此時,生成器11生成之第一圖像與從資料樣本x中獲取之第二圖像完全相同,判別器12無法判別第一圖像與第二圖像之真假,輸出之概率D為0.5。During the training process of the
於本申請實施例中,權重係指神經網路之權重數量,表徵神經網路之學習能力,所述學習能力與所述權重呈正相關關係。In the embodiment of the present application, the weight refers to the weight quantity of the neural network, which represents the learning ability of the neural network, and the learning ability is positively correlated with the weight.
參照圖2,圖2為神經網路20之示意圖。神經網路20之學習過程由訊號之正向傳播與誤差之反向傳播兩個過程組成。當訊號正向傳播時,資料樣本x從輸入層傳入,經隱藏層逐層處理後,向輸出層傳播。若輸出層之輸出y與期望輸出不符,則轉向誤差之反向傳播階段。誤差之反向傳播係將輸出誤差以某種形式藉由隱藏層向輸入層逐層反向傳播,並將誤差分攤給各層之所有神經單元,從而獲得各層神經單元之誤差訊號,此誤差訊號作為修正權重W之依據。Referring to FIG. 2 , FIG. 2 is a schematic diagram of the
於本申請實施例中,神經網路包括輸入層、隱藏層及輸出層。所述輸入層用於接收來自於神經網路外部之資料,所述輸出層用於輸出神經網路之計算結果,除輸入層和輸出層以外之其它各層均為隱藏層。所述隱藏層用於把輸入資料之特徵,抽象到另一個維度空間,以線性劃分不同類型之資料。In the embodiment of the present application, the neural network includes an input layer, a hidden layer and an output layer. The input layer is used to receive data from outside the neural network, the output layer is used to output the calculation results of the neural network, and all layers except the input layer and the output layer are hidden layers. The hidden layer is used to abstract the features of the input data into another dimensional space to linearly divide different types of data.
所述神經網路20之輸出y如公式(1)所示:
(1)
The output y of the
其中,x為資料樣本, 、 、 分別為隱藏層輸入 、 、 之啟動函數,W 1、W 2、W 3均為層與層之間之權重。 Among them, x is the data sample, , , input to the hidden layer , , In the activation function, W 1 , W 2 , and W 3 are the weights between layers.
採用梯度下降法更新權重W如公式(2)所示: (2) Use the gradient descent method to update the weight W as shown in formula (2): (2)
其中, 為更新後之權重,W為更新前之權重,Loss為損失函數, 為學習率,所述學習率係指權重W更新之幅度。 in, is the weight after update, W is the weight before update, Loss is the loss function, is the learning rate, and the learning rate refers to the magnitude of updating the weight W.
於本申請實施例中,損失函數之作用係衡量判別器對生成圖像判斷之能力。損失函數之值越小,說明於當前反覆運算中,判別器能夠有較好之性能,辨別生成器之生成圖像;反之,則說明判別器之性能較差。In the embodiment of the present application, the function of the loss function is to measure the ability of the discriminator to judge the generated image. The smaller the value of the loss function, it means that the discriminator can have better performance in the current iterative operation to distinguish the image generated by the generator; otherwise, it means that the performance of the discriminator is poor.
請一併參閱圖1至圖3,圖3為生成對抗網路優化方法之流程圖。所述生成對抗網路優化方法包括如下步驟:Please refer to FIG. 1 to FIG. 3 together. FIG. 3 is a flowchart of a method for optimizing a generative adversarial network. The generation confrontation network optimization method comprises the following steps:
S31,確定生成器之第一權重與判別器之第二權重,所述第一權重與所述第二權重相等。S31. Determine a first weight of the generator and a second weight of the discriminator, where the first weight is equal to the second weight.
於本申請實施例中,確定所述第一權重與所述第二權重之方法包括但不限於Xavier初始化、Kaiming初始化、Fixup初始化、LSUV初始化或轉移學習等。In the embodiment of the present application, the method for determining the first weight and the second weight includes but not limited to Xavier initialization, Kaiming initialization, Fixup initialization, LSUV initialization or transfer learning.
所述第一權重與所述第二權重相等,說明所述生成器與所述判別器具有相同之學習能力。The first weight is equal to the second weight, indicating that the generator and the discriminator have the same learning ability.
S32,訓練生成器並更新第一權重。S32. Train the generator and update the first weight.
所述第一權重之更新與生成器之學習率及損失函數相關,學習率根據訓練次數動態設置,損失函數 如公式(3)所示: (3) The update of the first weight is related to the learning rate and loss function of the generator, the learning rate is dynamically set according to the training times, and the loss function As shown in formula (3): (3)
其中,m為雜訊樣本z之個數, 係指第i個雜訊樣本, 係指藉由雜訊樣本 生成之圖像, 係指判別所述圖像係否為真之概率, 為所述第一權重。 Among them, m is the number of noise samples z, refers to the i-th noise sample, Noise samples generated image, means the probability of judging whether the image in question is real or not, is the first weight.
生成器之目標係最大化損失函數 ,盡可能地使生成樣本分佈擬合真實樣本分佈。 The objective of the generator is to maximize the loss function , to make the generated sample distribution fit the real sample distribution as much as possible.
S33,訓練判別器並更新第二權重。S33. Train the discriminator and update the second weight.
所述第二權重之更新與判別器之學習率及損失函數相關,學習率根據訓練次數動態設置,損失函數 如公式(4)所示: (4) The update of the second weight is related to the learning rate and loss function of the discriminator, the learning rate is dynamically set according to the training times, and the loss function As shown in formula (4): (4)
其中, 係指第i個真實圖像, 係指判別所述真實圖像 係否為真之概率, 為所述第二權重。 in, refers to the i-th real image, Refers to the identification of the real image is the probability of being true, is the second weight.
判別器之目標係最小化損失函數 ,盡可能地判別輸入樣本係真實圖像還係生成器生成之圖像。 The goal of the discriminator is to minimize the loss function , as much as possible to distinguish whether the input sample is a real image or an image generated by the generator.
S34,重複執行步驟S32與步驟S33,直至生成器與判別器均收斂。S34. Repeat step S32 and step S33 until both the generator and the discriminator converge.
於本申請實施例中,並不限定步驟S32與S33之執行順序,即於生成器與判別器之交替反覆運算訓練過程中,可以先訓練生成器,也可以先訓練判別器。In the embodiment of the present application, the execution order of steps S32 and S33 is not limited, that is, in the alternating and iterative operation training process of the generator and the discriminator, the generator can be trained first, and the discriminator can also be trained first.
本申請利用梯度下降法反覆運算更新所述第一權重 與所述第二權重 ,隨著訓練週期之加長動態調整生成器與判別器之學習率,直至所述生成器之損失函數 與所述判別器之損失函數 均收斂,從而得到最優之權重。 This application uses the gradient descent method to repeatedly calculate and update the first weight with the second weight , dynamically adjust the learning rate of the generator and the discriminator with the lengthening of the training period until the loss function of the generator and the loss function of the discriminator Both converge to obtain the optimal weight.
參照圖4,圖4為電子設備40之示意圖。所述電子設備40包括記憶體41及處理器42,所述記憶體41用以存儲電腦程式,所述電腦程式被所述處理器42調用時,實現本申請之生成對抗網路優化方法。Referring to FIG. 4 , FIG. 4 is a schematic diagram of an
所述電子設備40包括但不限於智慧型電話、平板、個人電腦(personal computer,PC)、電子書閱讀器、工作站、伺服器、個人數位助理(PDA)、可擕式多媒體播放機(Portable Multimedia Player,PMP)、MPEG-1音訊層3(MP3)播放機、移動醫療設備、相機和可穿戴設備中之至少一個。所述可穿戴設備包括附件類型(例如,手錶、戒指、手鐲、腳鏈、項鍊、眼鏡、隱形眼鏡或頭戴式設備(Head-Mounted Device,HMD))、織物或服裝集成類型(例如,電子服裝)、身體安裝類型(例如,皮膚墊或紋身)以及生物可植入類型(例如,可植入電路)中之至少一種。The
所述記憶體41用於存儲電腦程式和/或模組,所述處理器42藉由運行或執行存儲於所述記憶體41內之電腦程式和/或模組,以及調用存儲於記憶體41內之資料,實現本申請之生成對抗網路優化方法。所述記憶體41包括易失性或非易失性記憶體件,例如數位多功能盤(DVD)或其它光碟、磁片、硬碟、智慧存儲卡(Smart Media Card,SMC)、安全數位(SecureDigital,SD)卡、快閃記憶體卡(Flash Card)等。The
所述處理器42包括中央處理單元(Central Processing Unit,CPU)、數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、現場可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其它可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。The
可以理解,當所述電子設備40實現本申請之生成對抗網路優化方法時,所述生成對抗網路優化方法之具體實施方式適用於所述電子設備40。It can be understood that when the
上面結合附圖對本申請實施例作了詳細說明,但本申請不限於上述實施例,於所屬技術領域普通技術人員所具備之知識範圍內,還可以於不脫離本申請宗旨之前提下做出各種變化。此外,於不衝突之情況下,本申請之實施例及實施例中之特徵可以相互組合。The embodiments of the present application have been described in detail above in conjunction with the accompanying drawings, but the present application is not limited to the above embodiments. Within the scope of knowledge of those of ordinary skill in the art, various modifications can be made without departing from the purpose of the present application. Variety. In addition, the embodiments of the present application and the features in the embodiments can be combined with each other under the condition of no conflict.
10:生成對抗網路 11:生成器 12:判別器 z:雜訊樣本 x:資料樣本 D:真假判別之概率 20:神經網路 y:輸出 W 1, W 2, W 3:權重 :隱藏層輸入 :啟動函數 40:電子設備 41:記憶體 42:處理器 S31-S34:步驟 10: Generative confrontation network 11: Generator 12: Discriminator z: Noise sample x: Data sample D: Probability of true and false discrimination 20: Neural network y: Output W 1 , W 2 , W 3 : Weight : hidden layer input : start function 40: electronic equipment 41: memory 42: processor S31-S34: steps
圖1係生成對抗網路之示意圖。 圖2係神經網路之示意圖。 圖3係生成對抗網路優化方法之流程圖。 圖4係電子設備之示意圖。 Figure 1 is a schematic diagram of a generative adversarial network. Fig. 2 is a schematic diagram of a neural network. Fig. 3 is a flow chart of a method for optimizing a generative adversarial network. Fig. 4 is a schematic diagram of an electronic device.
無none
S31-S34:步驟 S31-S34: Steps
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW110118136A TWI769820B (en) | 2021-05-19 | 2021-05-19 | Method for optimizing the generative adversarial network and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW110118136A TWI769820B (en) | 2021-05-19 | 2021-05-19 | Method for optimizing the generative adversarial network and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
TWI769820B TWI769820B (en) | 2022-07-01 |
TW202247044A true TW202247044A (en) | 2022-12-01 |
Family
ID=83439567
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW110118136A TWI769820B (en) | 2021-05-19 | 2021-05-19 | Method for optimizing the generative adversarial network and electronic equipment |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI769820B (en) |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10803378B2 (en) * | 2017-03-15 | 2020-10-13 | Samsung Electronics Co., Ltd | System and method for designing efficient super resolution deep convolutional neural networks by cascade network training, cascade network trimming, and dilated convolutions |
US10679129B2 (en) * | 2017-09-28 | 2020-06-09 | D5Ai Llc | Stochastic categorical autoencoder network |
CN108665058B (en) * | 2018-04-11 | 2021-01-05 | 徐州工程学院 | Method for generating countermeasure network based on segment loss |
EP3816864A1 (en) * | 2019-10-28 | 2021-05-05 | Robert Bosch GmbH | Device and method for the generation of synthetic data in generative networks |
CN111583109B (en) * | 2020-04-23 | 2024-02-13 | 华南理工大学 | Image super-resolution method based on generation of countermeasure network |
CN112529772B (en) * | 2020-12-18 | 2024-05-28 | 深圳龙岗智能视听研究院 | Unsupervised image conversion method under zero sample setting |
CN112801902B (en) * | 2021-01-29 | 2022-06-21 | 福州大学 | Traffic image defogging method based on improved generation countermeasure network |
-
2021
- 2021-05-19 TW TW110118136A patent/TWI769820B/en active
Also Published As
Publication number | Publication date |
---|---|
TWI769820B (en) | 2022-07-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2017166449A1 (en) | Method and device for generating machine learning model | |
WO2020173237A1 (en) | Brain-like computing chip and computing device | |
US11275995B2 (en) | Information processing apparatus, ising device, and control method for information processing apparatus | |
US10558935B2 (en) | Weight benefit evaluator for training data | |
EP3117338A1 (en) | Alternative training distribution data in machine learning | |
US20210224647A1 (en) | Model training apparatus and method | |
WO2023005386A1 (en) | Model training method and apparatus | |
WO2020019102A1 (en) | Methods, systems, articles of manufacture and apparatus to train a neural network | |
US11842220B2 (en) | Parallelization method and apparatus with processing of neural network model for manycore system | |
US20220414661A1 (en) | Privacy-preserving collaborative machine learning training using distributed executable file packages in an untrusted environment | |
US11915141B2 (en) | Apparatus and method for training deep neural network using error propagation, weight gradient updating, and feed-forward processing | |
US11709783B1 (en) | Tensor data distribution using grid direct-memory access (DMA) controller | |
US11875256B2 (en) | Dynamic computation in decentralized distributed deep learning training | |
CN115374899A (en) | Optimization method for generation countermeasure network and electronic equipment | |
US20220012642A1 (en) | Dynamic network bandwidth in distributed deep learning training | |
US11977986B2 (en) | Dynamic computation rates for distributed deep learning | |
CN113240128B (en) | Collaborative training method and device for data unbalance, electronic equipment and storage medium | |
TWI769820B (en) | Method for optimizing the generative adversarial network and electronic equipment | |
CN114662646A (en) | Method and device for realizing neural network | |
CN109598344A (en) | Model generating method and device | |
TWI758223B (en) | Computing method with dynamic minibatch sizes and computing system and computer-readable storage media for performing the same | |
CN115577798A (en) | Semi-federal learning method and device based on random acceleration gradient descent | |
US11711407B2 (en) | Automated pausing of audio and/or video during a conferencing session | |
CN115146786A (en) | Method, device, system, medium, equipment and product for realizing federal learning | |
TW202201261A (en) | Considering Both Imbalanced Data and Generation of Adversarial Examples with HighRecall Requirements Method, System and Computer-readable Record Medium |