Upsampling with PixelShuffle_ICNR


(Zach Eberhart) #1

I’m trying to use fastai’s PixelShuffle_ICNR in a VAE and I need a sigmoid activation as the final layer – what would be the best way to do this?

My solution below works, but I know there has to be a better way to do it… Should I add a conv_layer(3, 3) at the end w/ the nn.Sigmoid() activation?

My code:

from fastai.layers import PixelShuffle_ICNR as shuffleblock

...

 self.decoder = nn.Sequential(
            
    shuffleblock(   1024, NDF * 8, scale = 2, leaky = True),
    shuffleblock(NDF * 8, NDF * 4, scale = 2, leaky = True),
    shuffleblock(NDF * 4, NDF * 2, scale = 2, leaky = True),
    shuffleblock(NDF * 2, NC     , scale = 2, leaky = True, blur = True),
    nn.Sigmoid()

)

Any other feedback welcome as well (am I getting the PixelShuffle wrapper completely wrong??) – thanks!