sunshineatnoon / paper-implementations Goto Github PK
View Code? Open in Web Editor NEWUse PyTorch to implement some classic frameworks
Use PyTorch to implement some classic frameworks
I tried backward errD((errD_fake + errD_real)*0.5) and original code only backward total generator loss, but in this code, the result worse than separate backward errD_fake and errD_real.
the output size of the convolutional layer is not 30*30?
Meanwhile, there shouldn't be a sigmoid layer at the end?
https://github.com/sunshineatnoon/Paper-Implementations/blob/master/cycleGAN/model/Discriminator.py
I am talking about vgg in
vgg.py
The model is inconsistent with pre-trained model provided torchvision package
from torchvision.models import vgg16
The pre-trained model in torchvision package as follow:
VGG(
(features): Sequential(
(0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(1): ReLU(inplace=True)
(2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(3): ReLU(inplace=True)
(4): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(5): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(6): ReLU(inplace=True)
(7): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(8): ReLU(inplace=True)
(9): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(10): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(11): ReLU(inplace=True)
(12): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(13): ReLU(inplace=True)
(14): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(15): ReLU(inplace=True)
(16): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(17): Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(18): ReLU(inplace=True)
(19): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(20): ReLU(inplace=True)
(21): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(22): ReLU(inplace=True)
(23): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(24): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(25): ReLU(inplace=True)
(26): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(27): ReLU(inplace=True)
(28): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(29): ReLU(inplace=True)
(30): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
)
(avgpool): AdaptiveAvgPool2d(output_size=(7, 7))
(classifier): Sequential(
(0): Linear(in_features=25088, out_features=4096, bias=True)
(1): ReLU(inplace=True)
(2): Dropout(p=0.5, inplace=False)
(3): Linear(in_features=4096, out_features=4096, bias=True)
(4): ReLU(inplace=True)
(5): Dropout(p=0.5, inplace=False)
(6): Linear(in_features=4096, out_features=1000, bias=True)
)
)
As you see, the model does not contain layer conv3_4, conv4_4, and conv5_4.
When I changed the input_nc and output_nc with 1,it came out such problem:
Traceback (most recent call last):
File "CycleGAN.py", line 209, in
outA = D_A(real_A)
File "/home/ccc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/ccc/cchoi/Paper-Implementations/cycleGAN/model/Discriminator.py", line 56, in forward
out = self.layer1(x)
File "/home/ccc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/ccc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/ccc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/home/ccc/anaconda2/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 301, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight[64, 1, 4, 4], so expected input[1, 3, 512, 512] to have 1 channels, but got 3 channels instead
Exception NameError: "global name 'FileNotFoundError' is not defined" in <bound method _DataLoaderIter.del of <torch.utils.data.dataloader._DataLoaderIter object at 0x2ac957b05d50>> ignored
Exception NameError: "global name 'FileNotFoundError' is not defined" in <bound method _DataLoaderIter.del of <torch.utils.data.dataloader._DataLoaderIter object at 0x2ac957b33550>> ignored
How could I train the dataset with just 1channel?
In script NeuralSytleTransfer/train.py
the open_and_resize function should not hard-code
styleImg = transform(util.open_and_resize_image(opt.style_image,256))
contentImg = transform(util.open_and_resize_image(opt.content_image,256))
rather, it should use parameters from opt.imageSize
In the cycle gan code i am getting the following error while training the model
File "CycleGAN.py", line 211, in
outA = D_A(real_A)
File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call
result = self.forward(*input, **kwargs)
File "/media/iab/New Volume/soumyadeep/Paper-Implementations-master/cycleGAN/model/Discriminator.py", line 57, in forward
out = self.layer2(out)
File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call
result = self.forward(*input, **kwargs)
File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/container.py", line 67, in forward
input = module(input)
File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call
result = self.forward(*input, **kwargs)
File "/media/iab/New Volume/soumyadeep/Paper-Implementations-master/cycleGAN/model/Discriminator.py", line 25, in forward
mean = torch.mean(t, 2).unsqueeze(2).expand_as(x)
File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/autograd/variable.py", line 725, in expand_as
return Expand.apply(self, (tensor.size(),))
File "/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/autograd/_functions/tensor.py", line 111, in forward
result = i.expand(*new_size)
RuntimeError: The expanded size of the tensor (32) must match the existing size (128) at non-singleton dimension 2. at /opt/conda/conda-bld/pytorch_1503966894950/work/torch/lib/THC/generic/THCTensor.c:323
PLEASE HELP !!
我试过按照代码中errD_fake和errD_real分别backward,D网络和G网络以及L1的loss都能下降,用errD去backward,errD_real迅速降到零,errD_fake一直在上升,这是为什么呢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.