コード例 #1
0
 def forward(self, x):
     out = F.Sigmoid(self.bn1(self.conv1(x)))
     out = F.Sigmoid(self.bn2(self.conv2(out)))
     out = self.bn3(self.conv3(out))
     out += self.shortcut(x)
     out = F.Sigmoid(out)
     return out
コード例 #2
0
 def forward(self, x):
     out = F.Sigmoid(self.bn1(self.conv1(x)))
     out = self.layer1(out)
     out = self.layer2(out)
     out = self.layer3(out)
     out = self.layer4(out)
     out = F.avg_pool2d(out, 4)
     out = out.view(out.size(0), -1)
     out = self.linear(out)
     return out
コード例 #3
0
 def __init__(self):
     super(CVAE, self).__init__()
     self.relu = nn.ReLU()
     self.sigmoid = nn.Sigmoid()
     # For Encoder
     self.fcE = nn.Linear(X_dim + y_dim, h_dim)
     self.fcE_mu = nn.Linear(h_dim, Z_dim)
     self.fcE_var = nn.Linear(h_dim, Z_dim)
     # For Decoder
     self.fcD1 = nn.Linear(Z_dim + y_dim, h_dim)
     self.fcD2 = nn.Linear(h_dim, X_dim)
                                    ('conv3_1', nn.Conv2d(64, 64, kernel_size=3,stride = 1, padding = 1)),
                                    ('relu3_1', nn.ReLU()),
                                    ('weight_norm3_1', nn.utils.weight_norm()), # Look into this later
                                    ('conv3_2', nn.Conv2d(64, 64, kernel_size=3,stride = 1, padding = 1)),
                                    ('relu3_2', nn.ReLU())
                                    ('weight_norm3_2', nn.utils.weight_norm()), # Look into this later
                                    ('pool3', nn.MaxPool2d(2,2)),

                                    ('fc4', nn.Linear(12288, 100)),
                                    ('tanh4' nn.Tanh()),
                                    ('fc5', nn.Linear(100,2)),
                                    ('tanh5' nn.Tanh()),
                                    ('fc6', nn.Linear(2,1)),
                                    # ('sigmoid6' F.Sigmoid())
                                                              ]))
  return F.Sigmoid(net)

class DiscriminatorNet(nn.Module):
  def __init__(self):
    super(DiscriminatorNet, self).__init__()
    
    self.net = nn.Sequential(OrderedDict([
                                            ('merge', nn.Conv2d(4, 3, kernel_size=1,stride = 1, padding = 0)),
                                            ('conv1', nn.Conv2d(3, 32, kernel_size=3,stride = 1, padding = 1)),
                                            ('relu1', nn.ReLU()),
                                            ('pool1',  nn.MaxPool2d(4,4)),

                                            ('conv2_1', nn.Conv2d(32, 64, kernel_size=3,stride = 1, padding = 1)),
                                            ('relu2_1', nn.ReLU()),
                                            ('conv2_2', nn.Conv2d(64, 64, kernel_size=3,stride = 1, padding = 1)),
                                            ('relu2_2', nn.ReLU()),