Skip to content

Instantly share code, notes, and snippets.

@FrancescoSaverioZuppichini
Created September 23, 2018 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrancescoSaverioZuppichini/abc4a138a23f20c2a84052340e960275 to your computer and use it in GitHub Desktop.
Save FrancescoSaverioZuppichini/abc4a138a23f20c2a84052340e960275 to your computer and use it in GitHub Desktop.
class MyModule(nn.Module):
def __init__(self, sizes):
super().__init__()
self.layers = nn.ModuleList([nn.Linear(in_f, out_f) for in_f, out_f in zip(sizes, sizes[1:])])
self.trace = []
def forward(self,x):
for layer in self.layers:
x = layer(x)
self.trace.append(x)
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment