Skip to content

Instantly share code, notes, and snippets.

View Jinsol-Lee's full-sized avatar

Jinsol Lee Jinsol-Lee

  • Georgia Institute of Technology
  • Atlanta, GA
View GitHub Profile
@Tushar-N
Tushar-N / hook_activations.py
Created August 3, 2018 00:06
Pytorch code to save activations for specific layers over an entire dataset
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as tmodels
from functools import partial
import collections
# dummy data: 10 batches of images with batch size 16
dataset = [torch.rand(16,3,224,224).cuda() for _ in range(10)]