李祖福
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Generative Models & Generative Adversarial Networks ###### tags: `Deep Learning for Computer Vision` ## From VAE to GAN We only care about generators when we train VAE, but the generated images may look fake, so we can use the GAN architecture to improve this problem. ![](https://i.imgur.com/wEXHzc4.png) ## Generative Adversarial Network * Generator to convert a vector $Z$ (sampled from $P_z$) into fake data $X$ (from $P_G$), while we need $P_G$ = Pdata * try to generate more realistic images to cheat discriminator * Discriminator classifies data as real or fake (1/0) * try to distinguish wheater the image is gerenrated or real ![](https://i.imgur.com/O4dClXz.png) ### Objective Function A **min-max game** on following function \begin{equation} \mathcal{L}_{GAN} = E[log(1-D(G(x)))] + E[logD(y)] \end{equation} * When we training the D, the G is fixed and we hope $D(G(x))$ is close to 0 * When we training the G, the D is fixed and we hope $D(G(x))$ is close to 1 * We hope $D(y)$ is close 1 because the y is the real image ![](https://i.imgur.com/tpDiLjJ.png) <img src="https://i.imgur.com/clT4es0.png" width="500"/> ![](https://i.imgur.com/SCNZqyp.png) ### How to solve Discriminator <img src="https://i.imgur.com/RaTWz5e.png" width="600"/> Apply formula of $f'(y) = \dfrac{a}{y}-\dfrac{b}{1-y}$ to $min G$, We can get the **optimal Discrimination**. ### How to solve Generator <img src="https://i.imgur.com/Wq7CxbE.jpg" width="600"/> ## Deep Convolutional GAN (DC-GAN) * ICLR 2016 * A CNN+GAN architecture * Empirically make training of GAN more stable ![](https://i.imgur.com/ZCBGjMd.png) * Example Results ![](https://i.imgur.com/PiB4CUc.jpg) ## Conditional GANs * ICLR 2016 * Conditional generative model p(x|y) instead of p(x) * Both G and D take the label y as an additional input ![](https://i.imgur.com/FPNWS1Y.png) where Y is label vactor like [1,0,0,0,0...] Given the same input $Z$, just choose a different label $Y$ to generate the corresponding category ![](https://i.imgur.com/e81WNiv.jpg) For example : * input real image $x_{male}$ and label $[1, 0]$ , Discriminator should output 1 * input real image $x_{male}$ and label $[0, 1]$ , Discriminator should output 0 * input **fake image** $x_{male}$ and label $[1, 0]$ , Discriminator should output 0 ## Problems in Training GANs ### Vanishing Gradients GAN training is often unstable, so training might not converge properly. JSD divergence will always be equal to the constant log2 if there is no overlap between the two distributions. which makes the network unable to learn through this loss function. ![](https://i.imgur.com/VMbPl36.png) **Discriminator cannot express how far the generated picture is from the real picture**. That is, there is no way to reflect the quality of the real picture. For example, the third picture has been regarded as an apple, but it is still classified as a fake picture (not an apple) ### Mode Collapse The generator only outputs a limited number of image variants regardless of the inputs. ![](https://i.imgur.com/4pkhhGq.png) In order to avoid being punished, the **Generator** becomes "lazy" and only generates similar samples. ### T-SNE https://openreview.net/pdf?id=rkmu5b0a- <img src="https://i.imgur.com/Lv1VcQm.png" width="400"/> ## Energy-Based GAN In order to avoid Vanishing Gradients. It can solve the traditional GAN only output 1 or 0 * Energy Function * Converting input data into scalar outputs, viewed as energy values * Desired configuration is expected to output low energy values & vice versa. * Energy Function as Discriminator * Use of autoencoder; can be pre-trained * **Reconstruction loss (L2-norm, cosin similarity...) outputs a range of values instead of binary logistic loss.** * Empirically better convergence <img src="https://i.imgur.com/A8X5K9k.png" width="300"/> The autoencoder can reconstruct the real data but not the fake data. The idea can be applied to the problem of **Anomaly Detection**. ### Example Results ![](https://i.imgur.com/UXEyk85.jpg) ## MSGAN In order to avoid Mode Collapse, add one more restriction to make two very similar input $Z$ them output become more difference * Mode Seeking Generative Adversarial Networks for Diverse Image Synthesis. * With the goal of producing diverse image outputs. * To address the **mode collapse** issue by **conditional GANs**. ![](https://i.imgur.com/Pm5d7RM.jpg) ### Proposed Regularization ![](https://i.imgur.com/InKd3Q5.jpg) ### Qualitative results #### Conditioned on paired images ![](https://i.imgur.com/xDZFA0k.jpg) #### Conditioned on unpaired images ![](https://i.imgur.com/PGANsQa.jpg) #### Conditioned on text ![](https://i.imgur.com/TMbjxKg.jpg) The input y does not have to be only one hot vector, it can be a text description. ## Style-based GAN * A Style-Based Generator Architecture for Generative Adversarial Networks (CVPR’19) * Design style-based generator to achieve high-resolution image synthesis * No particular designs on loss functions, regularization, and hyper-parameters ### Style-based generator ![](https://i.imgur.com/fpTiyer.png) ## SinGAN **Learning a Generative Model from a Single Natural Image** * Learning from a **single image** * Handle multiple image manipulation tasks * Super-resolution, style conversion, harmonization, image editing, et. ![](https://i.imgur.com/vQO32h4.jpg) <br> Change a image into different size, and then use these resize images to train each layer generator. The bottom generator only input a random vector, and the generator at a higher layer input the output of the previous layer and a random vector. ![](https://i.imgur.com/L1dagWy.jpg) ### Inference Stage for SinGAN ![](https://i.imgur.com/HTuhPjK.jpg) #### Paint-to-Image input image + z ![](https://i.imgur.com/oGIjBLE.jpg) #### Harmonization SinGAN can solve the problem that the background (style) of two images does not match For wxample, We can downsampling the picture into a small picture, and then generate a specific style through layers of generators (because these generators are trained to generate pictures of a specific style) ![](https://i.imgur.com/exefZCA.jpg) #### Editing ![](https://i.imgur.com/8FYSB3j.jpg) #### Number of scales/levels in SinGAN Putting downsampling images into different layers of generators will produce different results. For example, the image generated by the generator at the lower level is more similar with the style of training data; the image generated by the generator at the higher level has less change style. ![](https://i.imgur.com/Ek424O7.jpg)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully