This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| The function `torch_conv_layer_to_affine` takes a `torch.nn.Conv2d` layer `conv` | |
| and produces an equivalent `torch.nn.Linear` layer `fc`. | |
| Specifically, this means that the following holds for `x` of a valid shape: | |
| torch.flatten(conv(x)) == fc(torch.flatten(x)) | |
| Or equivalently: | |
| conv(x) == fc(torch.flatten(x)).reshape(conv(x).shape) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import os | |
| import shutil | |
| import warnings | |
| # Method definitions # | |
| def get_indentation(line): | |
| for i, char in enumerate(line): |