MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / __init__

Method __init__

pix2pix/net/Generator.py:12–24  ·  view source on GitHub ↗
(self,in_channels, out_channels, down=True, act="relu", use_dropout=False)

Source from the content-addressed store, hash-verified

10
11class Block(torch.nn.Module):
12 def __init__(self,in_channels, out_channels, down=True, act="relu", use_dropout=False):
13 super(Block, self).__init__()
14 self.conv = torch.nn.Sequential(
15 torch.nn.Conv2d(in_channels=in_channels,out_channels=out_channels,kernel_size=(4,4),
16 stride=(2,2),padding=(1,1),bias=False,padding_mode='reflect')
17 if down
18 else torch.nn.ConvTranspose2d(in_channels=in_channels,out_channels=out_channels,
19 kernel_size=(4,4),stride=(2,2),padding=(1,1),bias=False),
20 torch.nn.BatchNorm2d(num_features=out_channels),
21 torch.nn.ReLU() if act == "relu" else torch.nn.LeakyReLU(negative_slope=0.2)
22 )
23 self.use_dropout = use_dropout
24 self.dropout = torch.nn.Dropout(p=0.5)
25 def forward(self,x):
26 x = self.conv(x)
27 x = self.dropout(x) if self.use_dropout else x

Callers 1

__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected