Created
December 6, 2019 16:10
-
-
Save khakhlyuk/0e0e360849a7067dddfb9db9cd49e256 to your computer and use it in GitHub Desktop.
Lambda Layer Pytorch
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)) | |
| Lambda(lambda x: F.Relu(x[:, :, ::2, ::2])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment