Raj-Ghugare
    • 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
      • Invitee
    • 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
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync 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
Invitee
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
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Notes on "[Distilling the Knowledge in a Neural Network](https://arxiv.org/pdf/1503.02531.pdf)" ###### tags: `knowledge-distillation` `research paper notes` `distillation` #### Author [Raj Ghugare](https://github.com/RajGhugare19) ## A brief introduction: 1) Often predictions problems are tackled using the average outputs of an ensemble of large neural networks. This provides high accuracy but also has high computational requirements for being deployment friendly. 2) This paper further develops an approach to store the "knowledge" of such larger models in a small model which can be deployed for a large number of users. ## About the simplest approach: The first obvious thing that comes up when thinking about the knowledge of a Neural network are its parameters, which makes it difficult to think of ways to transfer knowledge to a smaller model because the smaller model can have only so many parameters.But the real objective of a neural network is to generalize well on previously unseen data. If a smaller neural network is taught how to generalize in the same way as these large learned ensembles of models, it would perform better than being directly trained on the same data set as the larger model. The probabilities assigned by the larger trained network to all classes for a data set can be used as soft-targets for the smaller model. At this point they talk about high entropy soft-targets being better as they carry more information. And have much less variance on the gradients between training examples. They provide a technique in which the temperature in the final layer softmax of the cumbersome model is increased so that it gives a soft-target. These Soft-targets are used to train the smaller network using the same temperature. ## Distillation: Temperature is a parameter of the softmax function used to convert the output logits into a probability distribution. $$q_{i} = \frac{exp(z_{i}/T)}{\Sigma_{i}exp(z_{j}/T)}$$ $T \rightarrow$ Temperature factor If T would be relatively higher, it would be as if all the logits are same... i.e. their probabilities would come closer.Using higher values of temperature provides the smaller network with the knowledge about which classes the larger network finds similar. ### Simplest form of distillation: 1) Form a transfer set. 2) Find a high value of temperature that produces suitable soft targets 3) Train the smaller network on these soft-targets using the same temperature in its output softmax layer. 4) After training use temperature = 1, prediction. ### Improvements: This method as proposed can be significantly improved if the labels for transfer data set are known.Then the small network can also be simultaneously trained to predict the correct label.Empirically it is found out that it is better to use a weighted average of the two objective functions. The first objective is the cross entropy with the soft-targets (using high value of temperature). The second objective function is the cross entropy with the correct labels(with temperature = 1). they found that the best results were generally obtained by using a considerably lower weight on the second objective function I will denote the smaller network as the student network and the larger one as the teacher network from now on. Let $z_{i}$ be the logits of the student network and $q_{i}$ be the respective probabilities generated from softmax. Similarly for the teacher network let $v_{i}$ be the logits and $p_{i}$ be the soft-targets generated after softmax. C is the cross-entropy loss between $q$ and $p$. #### Derivation of gradient: $$\frac {\partial C}{\partial z_{i}} = \frac{q_{i}-p_{i}}{T}$$ we know that, $$C = -\Sigma_j p_{j} log(q_{j})$$ We also know that $$q_{j} = \frac{exp(z_{j}/T)}{\Sigma_{k}exp(z_{k}/T)}$$ [Just differentiating the Softmax function] if $i = j$ $$\frac {\partial q_{j}}{\partial z_{i}} = \frac{q_{j}(1-q_{j})}{T}$$ if $i\neq j$ $$\frac {\partial q_{j}}{\partial z_{i}} = - \frac{q_{i}q_{j}}{T}$$ $$\frac {\partial C}{\partial z_{i}} = -\Sigma_{j} p_{j} \frac {\partial log(q_{j})}{\partial z_{i}}$$ $$ = -\Sigma_{j} \frac {p_{j}}{q_{j}}\frac {\partial q_{j}}{\partial z_{i}}$$ $$ = -\frac{p_{i}(1-q_{i})}{T} + \Sigma_{j \neq i}\frac{p_j q_{i}}{T}$$ $$ = (-1/T)* (p_{i} -p_{i} q_{i} - \Sigma_{j \neq i} p_{j}q_{i})$$ $$ = (-1/T) * (p_{i} - q_{i})$$ $$\frac {\partial C}{\partial z_{i}} = \frac{q_{i}-p_{i}}{T}$$ The assumption in the next step is: $$exp[e] = 1 + e$$ if $e$ is very small. ### Key implementation details: #### On MNIST: * While predicting soft-targets temperature used was 20.(When the student network had 300 or more nodes in its two hidden layers). * When the number of nodes was drastically reduced to 30 temperatures between 2 and 4.5 gave the best results.

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