Last active
September 26, 2017 20:22
-
-
Save rosenfeldamir/471b157f2081e38e672d11bc91479e1d to your computer and use it in GitHub Desktop.
create multiple convolutions to work on a single input in parallel.
This file contains 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
def makeSomeLayers(in_channels,out_channels,resolutions): | |
layers = [] | |
for r in resolutions: | |
layers.append(nn.Conv2d(in_channels=in_channels,out_channels=out_channels,kernel_size=r)) | |
return layers | |
class Net(nn.Module): | |
def __init__(self): | |
super(Net, self).__init__() | |
in_channels = 3 | |
out_channels = 64 | |
resolutions = [3,5,7,9,11] | |
self.convs = nn.ModuleList(makeSomeLayers(in_channels,out_channels,resolutions)) | |
def forward(self,x): | |
# call the various defined operations on the input... | |
outs = [op(x) for op in self.convs] | |
# do something with output... | |
x = ..... | |
return x | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment