-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Description
Hi Igor,
First of all, thank you for the repo, super cool and very usefull. Hovewer, I am sorry but I have to say it, all the examples in the readme use bad coding practices. Take this:
class ConvBlock(nn.Module):
def __init__(self):
super(ConvBlock, self).__init__()
block = [nn.Conv2d(...)]
block += [nn.ReLU()]
block += [nn.BatchNorm2d(...)]
self.block = nn.Sequential(*block)
def forward(self, x):
return self.block(x)
Why create a 1 item array every time and add it to block? It doesn't make sense, it is confusing and useless. Do this instead
class ConvBlock(nn.Module):
def __init__(self):
super(ConvBlock, self).__init__()
self.block = nn.Sequential(
nn.Conv2d(...),
nn.ReLU(),
nn.BatchNorm2d(...)
)
def forward(self, x):
return self.block(x)
Cleaner and faster to code, or even better:
class ConvBlock(nn.Sequential):
def __init__(self):
super().__init__( nn.Conv2d(...),
nn.ReLU(),
nn.BatchNorm2d(...))
No need to write the forward method.
Hope it helps and I hope to see better and better code in the future :)
IgorSusmelj and jpvcaetano
Metadata
Metadata
Assignees
Labels
No labels