{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"class CycGAN_Discriminator(nn.Module):\n  # Construire le discriminateur\n    def __init__(self, input_nc, ndf):\n\n        \"\"\"\n        Paramètres:\n        input_nc (int):   le nombre de canaux dans les images d'entrée\n        ndf (int):        le nombre de filtres dans la dernière couche de convolution\n        \"\"\"\n        super(CycGAN_Discriminator, self).__init__()\n        self.main = nn.Sequential(\n                                  nn.Conv2d(input_nc, ndf, 4, 2, 1, bias=False),\n                                  nn.BatchNorm2d(ndf),\n                                  nn.LeakyReLU(0.2, inplace=True),\n           \n            \n                                  nn.Conv2d(ndf, ndf * 2, 4, 2, 1, bias=False),\n                                  nn.BatchNorm2d(ndf * 2),\n                                  nn.LeakyReLU(0.2, inplace=True),\n            \n            \n                                  nn.Conv2d(ndf * 2, ndf * 4, 4, 2, 1, bias=False),\n                                  nn.BatchNorm2d(ndf * 4),\n                                  nn.LeakyReLU(0.2, inplace=True),\n            \n            \n                                  nn.Conv2d(ndf * 4, ndf * 8, 4, 2, 1, bias=False),\n                                  nn.BatchNorm2d(ndf * 8),\n                                  nn.LeakyReLU(0.2, inplace=True),\n            \n            \n                                  nn.Conv2d(ndf * 8, 1, 4, 1, 0, bias=False),\n                                  nn.Sigmoid()\n        )\n\n    def forward(self, input):\n        return self.main(input)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class CycGAN_Generator(nn.Module):\n    def __init__(self, input_nc, output_nc, ngf):\n\n\n        super(CycGAN_Generator, self).__init__()\n        self.main = nn.Sequential(\n            # Down sampling\n            nn.Conv2d(input_nc, ngf, 4, 2, 1, bias=False),\n            nn.LeakyReLU(0.2, inplace=True),\n            \n            nn.Conv2d(ngf, ngf*2, 4, 2, 1, bias=False),\n            nn.LeakyReLU(0.2, inplace=True),\n            \n            nn.Conv2d(ngf*2, ngf*4, 4, 2, 1, bias=False),\n            nn.LeakyReLU(0.2, inplace=True),\n            \n            nn.Conv2d(ngf*4, ngf*8, 4, 2, 1, bias=False),\n            nn.LeakyReLU(0.2, inplace=True),\n            \n            # Up sampling\n            nn.ConvTranspose2d(ngf * 8, ngf * 4, 4, 2, 1, bias=False),\n            nn.BatchNorm2d(ngf * 4),\n            nn.ReLU(True),\n            \n            nn.ConvTranspose2d(ngf * 4, ngf * 2, 4, 2, 1, bias=False),\n            nn.BatchNorm2d(ngf * 2),\n            nn.ReLU(True),\n            \n            nn.ConvTranspose2d(ngf * 2, ngf, 4, 2, 1, bias=False),\n            nn.BatchNorm2d(ngf),\n            nn.ReLU(True),\n            \n            nn.ConvTranspose2d(ngf, output_nc, 4, 2, 1, bias=False),\n            nn.Tanh()\n        )\n\n    def forward(self, input):\n        return self.main(input)","metadata":{},"execution_count":null,"outputs":[]}]}