Share your work here ✅

Nice! You can probably just use our existing callback for saving activations - or at least simplify your code using our HooksCallback:

http://docs.fast.ai/callbacks.hooks.html

Untested, but something like:

class StoreHook(HookCallback):
    def on_train_begin(self, **kwargs):
        super().on_train_begin(**kwargs)
        self.acts = []
    def hook(self, m, i, o): return o
    def on_batch_end(self, train, **kwargs): self.acts.append(self.hooks.stored)

You can pass a list of modules to the ctor to hook whatever layers you like.

18 Likes