torch-srgan icon indicating copy to clipboard operation
torch-srgan copied to clipboard

There might be some problem for your SRResNet model

Open jiaxue-ai opened this issue 8 years ago • 3 comments
trafficstars

As titled, your SRResNet might has some problem

  1. you forget the skip connection
  2. 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

jiaxue-ai avatar Feb 09 '17 21:02 jiaxue-ai

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.

huangzehao avatar Feb 10 '17 03:02 huangzehao

please look at torch official website https://github.com/torch/nn/blob/master/doc/simple.md#nn.PixelShuffle screen shot 2017-02-09 at 10 58 09 pm

jiaxue-ai avatar Feb 10 '17 03:02 jiaxue-ai

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.

huangzehao avatar Feb 10 '17 04:02 huangzehao