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
| from google.colab import drive | |
| drive.mount('/drive') | |
| %cd '/drive/My Drive/thesis/fixedconv/' |
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
| planes = 3 | |
| k_2d = np.zeros((5,5)) | |
| k_3d = k_2d * np.array([1] * planes).reshape(planes, 1, 1) |
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
| class Lambda(nn.Module): | |
| def __init__(self, func): | |
| super().__init__() | |
| self.func = func | |
| def forward(self, x): | |
| return self.func(x) | |
| # use | |
| Lambda(lambda x: x.view(x.size(0), -1)) |
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
| x.element_size() * x.nelement() |
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 gc | |
| del file_to_be_deleted | |
| gc.collect() |
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
| sudo py-spy record -r 100 -d 30 -o profile.svg -- python file.py | |
| sudo py-spy top -r 100 -- python file.py |