Skip to content

Instantly share code, notes, and snippets.

@FrancescoSaverioZuppichini
Created September 23, 2018 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrancescoSaverioZuppichini/8b13a783083b1b8d3b38900d8a53e48b to your computer and use it in GitHub Desktop.
Save FrancescoSaverioZuppichini/8b13a783083b1b8d3b38900d8a53e48b to your computer and use it in GitHub Desktop.
def conv_block(in_f, out_f, activation='relu', *args, **kwargs):
activations = nn.ModuleDict([
['lrelu', nn.LeakyReLU()],
['relu', nn.ReLU()]
])
return nn.Sequential(
nn.Conv2d(in_f, out_f, *args, **kwargs),
nn.BatchNorm2d(out_f),
activations[activation]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment