Closed saurabh502 closed 5 years ago
Hi @saurabh502,
The fastai's DynamicUnet
has some hardcoded part, you can request them to make it work for general cases.
In the DynamicUnet
, the base arch downsamples, and the UnetBlock
upsamples. For se_resnext101_32x4d
, if the input size is 256, it's downsampled to 8, if each step halves it, then it's 4 steps (128, 64, 32, 16) in between. Then the UnetBlock
upsamples it, in this case, we need four UnetBlock
's, however, fastai only adds three.
Why? Each UnetBlock
upsamples by a factor of 2, and the current fastai logic thinks in the base arch, each time it downsamples by a factor of 2, but that's not the case for Cadene's se_resnext101_32x4d
, in which the layer0
reduced the input size by a factor of 4.
You can see it by looking at the sfs_szs
(second line in the __init__
of DynamicUnet
). For se_resnext101_32x4d
, the sfs_szs
is [64, 64, 32, 16, 8]; while for resnet18
, it's [128, 128, 128, 64, 64, 32, 32, 16, 8]. You can see for the resnet18
, if you have an input size of 256, the size is halved very time. The sfs_szs
is used later to determine how many UnetBlock
to include. The _get_sfs_idxs
thinks only three UnetBlock
is needed for se_resnext101_32x4d
, then at the MergeLayer
part mismatch occurs. If you downsample you need to upsample back, otherwise it can't merge with original.
You can also change the DynamicUnet
code to work temporarily, but I think you may want to tell fastai about this.
Thank you for your suggestions!
Hi, When I am trying to use unet_learner of fastai with se_resnext101_32x4d I am getting below error: `--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last)