Akshay Kulkarni
    • 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
    # Notes on "[Data-Free Learning of Student Networks](https://arxiv.org/abs/1904.01186)" ###### tags: `notes` `knowledge-distillation` `adversarial` Author: [Akshay Kulkarni](https://akshayk07.weebly.com/) ## Brief Outline - The pre-trained teacher network is considered as a fixed discriminator and a generator generates training samples which can obtain maximum response from the discriminator. - Simultaneously, a smaller network is trained using the generated data and the teacher network. ## Introduction - Most existing network compression and speed-up algorithms have a strong assumption that the original training data is available. However, training data may be unavailable due to privacy and transmission limitations. - Sometimes, the parameters and architecture of pre-trained networks may be unknown, except the input and output layers. - Thus, conventional methods won't work when either of the above 2 constraints apply. - Two methods have been proposed before this to work without original training data: - [Lopes et. al. 2017](https://arxiv.org/abs/1710.07535) utilized 'meta-data' (like means and standard deviations of activations from each layer) recorded from the original training dataset. However, those are not generally provided in most cases. - [Srinivas and Babu, 2015](https://arxiv.org/abs/1507.06149) compressed the pretrained network by merging similar neurons in fully connected layers. - The given heavy neural network is regarded as a fixed discriminator. - Then, a generative network is established for alternating the original training set by extracting information from the network during the adversarial procedure, which can be utlized for learning smaller networks with acceptable performance. ## Methodology ![DAFL Overview](https://i.imgur.com/SQyhKrs.png) ### Teacher-Student Interactions - Let $\mathcal{N}_T$ and $\mathcal{N}_S$ denote the original pre-trained CNN (teacher) and the desired portable network (student) respectively. - The student network can be optimized using $$ \mathcal{L}_{KD} = \frac{1}{n}\sum_i \mathcal{H}_{cross} (y_S^i, y_T^i) \tag{1} $$ - Here, $\mathcal{H}_{cross}$ is the cross-entropy loss, $y_T^i=\mathcal{N}_T(x^i)$ and $y_S^i=\mathcal{N}_S(x^i)$ are the outputs of teacher network $\mathcal{N}_T$ and student network $\mathcal{N}_S$, respectively. ### GAN for Generating Training Samples - They exploit GAN to generate training samples utilizing the available information of the given network (teacher). - Assuming some familiarity with GANs (if not refer [this blog by Lilian Weng](https://lilianweng.github.io/lil-log/2017/08/20/from-GAN-to-WGAN.html) or [my notes on a review paper on GANs](https://hackmd.io/fWTf_RCBTOKf5IkV6A7Fag)), the loss function for vanilla GANs is: $$ \mathcal{L}_{GAN} = \mathbb{E}_{y\sim p_{data}(y)}[\log D(y)] + \mathbb{E}_{z\sim p_z(z)}[\log(1 - D(G(z)))] \tag{2} $$ - [Odena, 2016](https://arxiv.org/abs/1606.01583) suggested that the tasks of discrimination and classification can improve each other. Instead of training a new $D$, the given teacher network can extract semantic features from images, since it has been trained on large scale datasets. - However, using the teacher as the discriminator, the output is to classify images to different concept sets, instead of indicating the reality of the images (as in vanilla GANs). - Thus, the loss function of GANs is inapplicable to approximate the original training set. They conduct analysis on real images and their responses on the teacher network and devise new loss functions based on their observations. ### Training Procedure #### One-Hot Loss - Denote the generator and teacher network as $G$ and $\mathcal{N}_T$ respectively. Given a set of random vectors $\{z^1, z^2, \dots, z^n\}$, the images generated from these are $\{x^1, x^2, \dots, x^n\}$ where $x^i=G(z^i)$. - Inputting these images into $\mathcal{N}_T$, outputs are $\{y_T^1, y_T^2, \dots, y_T^n\}$ with $y_T^i=\mathcal{N}_T(x^i)$. The predicted labels $\{t^1, t^2, \dots, t^n\}$ are calculated (as usual) using $t^i=\arg \max_j(y^i_T)_j$. - If the images generated by $G$ follow the same distribution as the training data of $\mathcal{N}_T$, they should have similar outputs as the training data. - Thus, they introduce a *one-hot loss*, which encourages the outputs of generated images by the teacher network to be close to one-hot like vectors. Taking $\{t^1, t^2, \dots, t^n\}$ as pseudo ground truth labels, the one-hot loss is given by $$ \mathcal{L}_{oh} = \frac{1}{n} \sum_i \mathcal{H}_{cross}(y^i_T, t^i) \tag{3} $$ - Here, $\mathcal{H}_{cross}$ is the cross entropy loss function. Using this, they pursue generation of synthetic images exclusively compatible with $\mathcal{N}_T$ instead of general real images. - Basically, they try to force the outputs of generated images to be closer to one-hot which implies those generated images will be more like the training data (since only the training data type images will get one-hot type output from $\mathcal{N}_T$). #### Activation Loss - Features extracted by convolution filters are supposed to contain valuable information about the input images. - Denote features of $x^i$ extracted by $\mathcal{N}_T$ as $f_T^i$ (the output before the fully-connected layer). Since, the filters in $\mathcal{N}_T$ have been trained to extract intrinsic patterns in the training data, the feature maps tend to receive higher activations if input images are real. Thus, *activation loss* is formulated as $$ \mathcal{L}_a = -\frac{1}{n}\sum_i ||f_T^i||_1 \tag{4} $$ - Here, $||.||_1$ is the conventional $l_1$ norm. #### Information Entropy Loss - Usually, to ease the training procedure, the number of training examples in each category is balanced. Thus, they employ an information entropy loss to measure the class balance of generated images. - Given a probability vector $p=(p_1, p_2, \dots, p_k)$, the information entropy (which measures the degree of confusion) of $p$ is calculated as $\mathcal{H}_{info}(p)=-\frac{1}{k}\sum_i p_i \log(p_i)$ - This value indicates the amount of information in $p$ (and is maximum when all variables are $\frac{1}{k}$). - Given a set of output vectors $\{y^1_T, y^2_T, \dots, y^n_T\}$, where $y_T^i=\mathcal{N}_T(x^i)$, the frequency distribution of generated images for every class is $\frac{1}{n}\sum_i y_T^i$. The *information entropy loss* of generated images is defined as $$ \mathcal{L}_{ie}=-\mathcal{H}_{info}(\frac{1}{n}\sum_i y_T^i) \tag{5} $$ - When the loss is minimized, every element in vector $\frac{1}{n}\sum_i y_T^i$ would be $\frac{1}{k}$, which implies that $G$ could generate images of each category with roughly the same probability (thus leading to a balanced set of synthetic images). #### Combining the 3 losses - The final objective function is $$ \mathcal{L}_{total} = \mathcal{L}_{oh} + \alpha \mathcal{L}_a + \beta \mathcal{L}_{ie} \tag{6} $$ - Here, $\alpha$ and $\beta$ are hyperparameters for balancing the three different terms. - Note that [Simonyan et. al. 2013](https://arxiv.org/abs/1312.6034) and [Mahendran and Vedaldi, 2014](https://arxiv.org/abs/1412.0035) synthesized images by optimizing the input of the NN using backprop. However, it is difficult to generate abundant images since each synthetic image leads to an independent optimization problem solved by backprop. - In contrast, this method can imitate the training data distribution directly, which is more flexible and efficient to generate new images. ![DAFL Algorithm](https://i.imgur.com/DLWwte4.png) ### Optimization - Training is done in 2 steps as shown in above Algorithm. - The paper also mentions how gradients for loss functions in Eq. 4 and 5 can be calculated. Both are straightforward derivations (single step, at most two) and can be seen in the paper on page 5 if required (won't be required for implementation based on autograd packages). ## Experiments ### Ablation Experiments ![Ablation Expts](https://i.imgur.com/5mepSfg.png) - This table shows the results of the ablation experiments. They suggest that each component of $\mathcal{L}_{total}$ is meaningful. - By applying the proposed method, $G$ can generate balanced samples from different classes with a similar distribution as that in the original dataset, which is effective for training the student network. ## Conclusion - This method can perform Knowledge Distillation without detailed architecture information and without training data. - They present a novel framework to train a generator to approximate the original dataset without training data. Then, a portable network can be learned effectively through the KD scheme.

    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