Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question in main.py #50

Open
yangyingni opened this issue Aug 27, 2019 · 1 comment
Open

Question in main.py #50

yangyingni opened this issue Aug 27, 2019 · 1 comment

Comments

@yangyingni
Copy link

def train(epoch):
epoch_loss = 0
model.train()
for iteration, batch in enumerate(training_data_loader, 1):
       input, target, bicubic = Variable(batch[0]), Variable(batch[1]), Variable(batch[2]),

What does 'input, target, bicubic = Variable(batch[0]), Variable(batch[1]), Variable(batch[2])' mean?
I tried to add some layers in your model,But it shows 'RuntimeError:The size of Tensor a(160) must match the size of tensor b(80) at non-singleton dimension 3'.I am confused.I will be thankful if you can answer me.Thanks.

@danielkovacsdeak
Copy link

Hi,
Since this is in main.py it's about training. The training process uses the high resolution (HR) training images, downscales to get the low res (LR) input image, and upscales the input image to get bicubic. It doesn't do that with the full image, only a random patch of it. The patch size is a parameter of main.py (default is 40x40). The data loader picks a training HR image, downscales it by the scaling_factor to get the LR image. Then it extracts the patch from the LR image, and the corresponding larger patch from the HR image. It also upscales the small patch to get the bicubic (see dataset.py for details). The default batch is 1, so by default, it does the process with one single image in each iteration, but if you change the batch to larger numbers then obviously it repeats it that many times. In the code snippet you quoted, the data is passed from the data loader (batch) to these new variables (input, target, and bicubic).
(It also turns the data to torch's Variable class instead of eg. a numpy array or whatever the original data format is.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants