当前位置:网站首页>Gan model architecture in mm
Gan model architecture in mm
2022-07-03 00:28:00 【Kun Li】
mmgeneration Medium GAN The architecture of includes , Enter a real image , If it's a condition gan Words , What you input is a real image and the corresponding label ,
1. First, train the discriminator , The gradient in the discriminator is saved during training , And the discriminator optimizer zero_grad(),gan There is an optimizer in the generator and the discriminator , It's actually two relatively independent training processes .
2. When training the discriminator, the generator is also used to generate a false sample , Note that the generator at this time is not trained , Just generate a fake sample , In terms of gan when , There is also a batch_accumulation_step Steps for , It will train several more times during generator training .
3. Use a discriminator to distinguish between true samples and false samples , Calculate the loss of discriminator training , natural ganloss And the corresponding auxiliary losses , Put it in disc_auxiliary_loss in , Feeling gan There are not many directions that can be expanded in , Architecturally speaking transformers perhaps self-attention And so on. , In theory, it is basically a loss function ,l Some operations on constraints , So at this time gen_auxiliary_loss Is a different point . The discriminator's loss It is essentially a two category , Negative sample input , The label given is 0, The label of positive sample input is 1.
4. After calculating the loss ,loss_disc.bachward() Back propagation ,optimizer['disciminator'].step() Gradient update , Here the discriminator is trained .
5. Conduct 5-8 After the discriminator training of the wheel, start the steering generator training , In fact, the gradient is cleared before each training , It is equivalent to not accumulating gradients in each round , First, the gradient of the discriminator is not saved , Notice when training the discriminator at the beginning , The gradient of the discriminator is preserved , Then the gradient of the generator is zero_grad().
6. Training generator , The input of the generator is still noise , After getting the image of the generator , Perform a discriminator decision , The last layer of the discriminator is usually a Linear(n,1) The layer , That is, the output is N,1 Dimensional , Input to gen_loss in , here gen_loss The middle core is also an auxiliary loss gen_auxiliary_loss in , Some may also be added here l Constraints and so on .
7. After calculating the loss ,loss_gen.backward() Back propagation ,optimizer['generator'].step() Gradient update , Generator training complete .
The figure above shows the structure of a typical generator and discriminator , In generator , We need a module that converts noise vectors into two-dimensional features , That is to say noise2feat block. Next, several upsampling blocks are needed to convert the low-resolution features into high-resolution features , stay DCGAN in , We use transposed convolution To achieve . Last , Need one to_rgb Block to map the number of channels of the feature graph to 3 passageway , So as to generate pictures . The discriminator is actually an inversion of the generator , We need to pass img2feat And a large number of down sampled blocks will continuously reduce the resolution of the feature map , Finally delivered to decision head, To judge the current input image .
边栏推荐
猜你喜欢
How QT exports data to PDF files (qpdfwriter User Guide)
带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)
Digital collection trading website domestic digital collection trading platform
秒杀系统设计
How do educators find foreign language references?
布隆过滤器
Bloom filter
监控容器运行时工具Falco
多进程编程(一):基本概念
Interface difference test - diffy tool
随机推荐
Define MySQL function to realize multi module call
University of Toronto:Anthony Coache | 深度强化学习的条件可诱导动态风险度量
Where can I find the English literature of the thesis (except HowNet)?
Should you study kubernetes?
FRP reverse proxy +msf get shell
CMake基本使用
Nc20806 District interval
Xcode real machine debugging
collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
One of the reasons why setinterval timer does not take effect in ie: the callback is the arrow function
微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!
字符设备注册常用的两种方法和步骤
布隆过滤器
Additional: token; (don't read until you finish writing...)
About the practice topic of screen related to unity screen, unity moves around a certain point inside
Slf4j + logback logging framework
Pageoffice - bug modification journey
详解用OpenCV的轮廓检测函数findContours()得到的轮廓拓扑结构(hiararchy)矩阵的意义、以及怎样用轮廓拓扑结构矩阵绘制轮廓拓扑结构图
论文的设计方案咋写?