Using Forward Hooks to save intermediate layer features

I created a notebook on how to save intermediate layer features using pytorch and fastai library. I more or less re-use existing fastai code and bcolz for faster appending of numpy arrays.

Saving intermediate layer features can be extremely important in many cases. Obvious use cases include using cnn features as an input to another model, appending other features with the cnn features, training only the last few layers and freezing the previous layers etc.

Link to the notebook: https://github.com/TheShadow29/FAI-notes/blob/master/notebooks/Using-Forward-Hook-To-Save-Features.ipynb

As always, feel free to create an issue if there is something amiss, or report it here.

7 Likes

Thank you!