Skip to content

Instantly share code, notes, and snippets.

View MattSegal's full-sized avatar
💭
Recovering engineering student

Matt Segal MattSegal

💭
Recovering engineering student
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)]