torch-srgan
torch-srgan copied to clipboard
There might be some problem for your SRResNet model
As titled, your SRResNet might has some problem
- you forget the skip connection
- after pixelshuffle, the number of channels should be divided by 2 instead of 4 this might be correct one
function defineSRResNet()
local SRResNet = nn.Sequential()
local residualPart = nn.Sequential()
residualPart:add(layer(basicblock,64,5,1))
residualPart:add(nn.SpatialConvolution(64, 64, 3, 3, 1, 1, 1, 1))
residualPart:add(nn.SpatialBatchNormalization(64))
SRResNet:add(nn.SpatialConvolution(3, 64, 3, 3, 1, 1, 1, 1))
SRResNet:add(nn.ReLU(true))
SRResNet:add(nn.ConcatTabel()
:add(residualPart)
:add(shortcut(64,64,1)))
SRResNet:add(nn.CAddTable(true))
SRResNet:add(nn.SpatialConvolution(64, 256, 3, 3, 1, 1, 1, 1))
SRResNet:add(nn.PixelShuffle(2))
SRResNet:add(nn.ReLU(true))
SRResNet:add(nn.SpatialConvolution(128, 256, 3, 3, 1, 1, 1, 1))
SRResNet:add(nn.PixelShuffle(2))
SRResNet:add(nn.ReLU(true))
SRResNet:add(nn.SpatialConvolution(128, 3, 3, 3, 1, 1, 1, 1))
return SRResNet
end
Hi, thanks for your carefully review. (1) This implementation is based on the the v2 version of paper srgan, and there is not skip-connection. I also have not time to update this repo. (2) Pixelshuffle(scale) convert (B, C * scale * scale, H, W) to (B, C, H * scale, W * scale), So I think it's no problem in my implementation.
please look at torch official website
https://github.com/torch/nn/blob/master/doc/simple.md#nn.PixelShuffle

Hi, there maybe a typo in the readme of PixelShuffle. You can not convert a tensor of shape [C * r, H, W] to a tensor of shape [C, H * r, W * r]. The number of elements in [C * r, H, W] is C * H * W * r while it is C * H * W * r * r in [C, H * r, W * r]. Check this https://github.com/torch/nn/blob/master/PixelShuffle.lua#L4. Thanks.